Chef has decided to start home delivery from his restaurant. He hopes that he will get a lot of orders for delivery, however there is a concern. He doesn't have enough work forces for all the deliveries.  For this he has came up with an idea - he will group together all those orders which have to be delivered in nearby areas. 

In particular, he has identified certain bidirectional roads which he calls as fast roads. They are short and usually traffic free, so the fast travel is possible along these roads. His plan is that he will send orders to locations A and B together if and only if it is possible to travel between A and B using only fast roads. Your task is, given the configuration of fast roads, identify which orders are to be sent together.

-----Input-----
First line of input contains an integer T, the number of test cases. Then T test cases follow. First line of each test case contains two space separated integers N and M, denoting number of locations and the number of fast roads. Then M lines follow each containing two space separated integers A and B, denoting that there is a fast road between locations A and B. Assume that locations are indexed by numbers from 0 to N-1. 

Next line contains an integer Q denoting the number of queries. Each of the next Q lines contain two integers X and Y. For each query you have to find out if orders meant for locations X and Y are to be sent together or not.

Note that there might be multiple fast roads between same pair of locations, also there might be a fast road that links a location to itself.

-----Output-----
For each test case print Q lines - one for each query. Output "YO" if the orders are to be 
delivered together and "NO" otherwise (quotes for clarity).

-----Constraints-----
1 ≤ T ≤ 100
1 ≤ N ≤ 100
1 ≤ M ≤ 1000
0 ≤ A, B, X, Y ≤ N-1
1 ≤ Q ≤ 3000

-----Example-----
Input:
1
4 2
0 1
1 2
3
0 2
0 3
2 1

Output:
YO
NO
YO

-----Warning!-----
There are large input and output files in this problem. Make sure you use fast enough I/O methods.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'from collections import defaultdict\r\n \r\nclass Graph:\r\n \r\n    def __init__(self,vertices):\r\n \r\n        self.graph = defaultdict(list)\r\n        self.DFSList = defaultdict(list)\r\n        \r\n        for i in range(0,vertices):\r\n        \tself.graph[i]=[]\r\n        \tself.DFSList[i]=[]\r\n \t\r\n\r\n    def addEdge(self,u,v):\r\n        if u!=v:\r\n        \tself.graph[u].append(v)\r\n        \tself.graph[v].append(u)\r\n        \t\r\n    def DFSUtil(self,v,visited,n):\r\n \r\n        visited[v]= True\r\n        self.DFSList[n].append(v)\r\n       \r\n        \r\n        for i in self.graph[v]:\r\n            if visited[i] == False:\r\n                self.DFSUtil(i, visited,n)\r\n \r\n    def DFS(self,v):\r\n \r\n        visited = [False]*(len(self.graph))\r\n        self.DFSUtil(v,visited,v)\r\n \r\nt=int(input())\r\nfor z in range(0,t):\r\n\tn,m=map(int,input().split())\r\n\tg = Graph(n)\r\n\r\n\tfor M in range(0, m):\r\n\t\tu,v = map(int,input().split())\r\n\t\tg.addEdge(u,v)\r\n\t\r\n\tfor i in range(0,n):\r\n\t\tg.DFS(i)\r\n\t\t\r\n\tq = int(input())\r\n\tfor Q in range(0, q):\r\n\t\tu,v = map(int,input().split())\r\n\t\tif v in g.DFSList[u]:\r\n\t\t\tprint("YO")\r\n\t\telse:\r\n\t\t\tprint("NO")\r\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 17127