编辑代码

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



void (async function () {
  const str = await readline();
  const n = Number(await readline());
  const nums = [];
  for (let i = 0; i < n; i++) {
    nums.push(Number(await readline()));
  }
  const vals = [];
  let i = 0;
  while (i < str.length) {
    const tag = parseInt(str.slice(i, i + 2), 16);
    const length = parseInt(str.slice(i + 2, i + 4), 16);
    // const content = str.slice(i + 4, i + 4 + length * 2);
    const valOffsets = Math.floor((i + 5) / 2);
    vals.push([tag, length, valOffsets]);
    i += length * 2 + 4;
  }
  nums.forEach((num) => {
    const val = vals.filter((val) => val[0] == num);
    if (val.length > 0) {
      console.log(val[0][1], val[0][2]);
    } else {
      console.log(0, 0);
    }
  });
})();