$N$ cows ($1 \le N \le 1000$), conveniently numbered $1 \ldots N$, attend a tea time every day. $M$ ($1 \le M \le 2000$) unique pairs of those cows have already met before the first tea time. Pair $i$ is given by two different integers $A_i$ and $B_i$ ($1 \le A_i \le N$; $1 \le B_i \le N$). The input never lists a pair of cows that have met more than once.
At each tea time, any two cows $i$ and $j$ that have both met a mutual friend cow $k$ will meet during that tea time, expanding their circle of acquaintances.
Tea times are held until no new meetings occur. For each of $Q$ ($1 \le Q \le 100$) queries, determine whether the two cows have met by then. Query $j$ consists of two different cows $X_j$ and $Y_j$ ($1 \le X_j \le N$; $1 \le Y_j \le N$).
For example, suppose that among cows $1$ through $5$ we know that cow $2$ has met cow $5$, cow $2$ has met cow $3$, and cow $4$ has met cow $5$; see (a) below.
2---3 2---3 2---3
\ |\ | |\ /|
1 \ --> 1 | \ | --> 1 | X |
\ | \| |/ \|
4---5 4---5 4---5
(a) (b) (c)
In the first tea time, cow $2$ meets cow $4$ and cow $3$ meets cow $5$; see (b). In the second tea time, cow $3$ meets cow $4$; see (c).
Y if the two cows in query $j$ have met, or N if they have not.