编辑代码

// 设置标准输入接口
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void (async function () {
  const n = Number(await readline());
  const map = new Map();
  for (let i = 0; i < n; i++) {
    const [a, b] = (await readline()).split(" ");
    map.set(b, a);
  }
  const arr = (await readline()).split(" ");
  const res = [];
  arr.forEach((element) => {
    if (!map.has(element) || !arr.includes(map.get(element))) res.push(element);
  });
  console.log(res.join(" "));
})();