#758. 【模板】调查

【模板】调查

No testdata at current.

No submission language available for this problem.

Background

许多人需要进行梳理亲属关系。

Description

你将会得到 n 组亲属关系,每组会告知两个人 a, b 是亲属关系。之后将会有 q 组询问,每次询问两个人 x,y 是否为亲属关系,若是则 yes,否则 no

Format

Input

输入第一行一个整数 n,之后有 n 行,每行两个整数 a,b 表示 a,b 为亲属关系。

第 n + 2 行有一个整数 q,之后有 q 行,每行两个整数 x,y, 表示询问 x, y 是否是亲属关系。

Output

输出有 q 行,每行对应一次询问的回答。若 x y 是亲属关系,则 yes,否则 no。

Samples

123 500
623

Limitation

1s, 1024KiB for each test case.