Bear and Chemistry

题意翻译

给定一张 $n$ 个点 $m$ 条边的初始无向图。 $q$ 次询问,每次询问给定一个点集 $V$ 和边集 $E$。 你需要判断,将 $E$ 中的边加入初始无向图之后,$V$ 中任意两个点 $x,y$ 是否都能**在每条边至多经过一次**的情况下从 $x$ 到 $y$ 再回到 $x$。 $n,m,q,\sum |V|, \sum |E| \le 3 \times 10^5$,强制在线。

题目描述

Limak is a smart brown bear who loves chemistry, reactions and transforming elements. In Bearland (Limak's home) there are $ n $ elements, numbered $ 1 $ through $ n $ . There are also special machines, that can transform elements. Each machine is described by two integers $ a_{i},b_{i} $ representing two elements, not necessarily distinct. One can use a machine either to transform an element $ a_{i} $ to $ b_{i} $ or to transform $ b_{i} $ to $ a_{i} $ . Machines in Bearland aren't very resistant and each of them can be used at most once. It is possible that $ a_{i}=b_{i} $ and that many machines have the same pair $ a_{i},b_{i} $ . Radewoosh is Limak's biggest enemy and rival. He wants to test Limak in the chemistry. They will meet tomorrow and both of them will bring all their machines. Limak has $ m $ machines but he doesn't know much about his enemy. They agreed Radewoosh will choose two distinct elements, let's denote them as $ x $ and $ y $ . Limak will be allowed to use both his and Radewoosh's machines. He may use zero or more (maybe even all) machines to achieve the goal, each machine at most once. Limak will start from an element $ x $ and his task will be to first get an element $ y $ and then to again get an element $ x $ — then we say that he succeeds. After that Radewoosh would agree that Limak knows the chemistry (and Radewoosh would go away). Radewoosh likes some particular non-empty set of favorite elements and he will choose $ x,y $ from that set. Limak doesn't know exactly which elements are in the set and also he doesn't know what machines Radewoosh has. Limak has heard $ q $ gossips (queries) though and each of them consists of Radewoosh's machines and favorite elements. For each gossip Limak wonders if he would be able to succeed tomorrow for every pair $ x,y $ chosen from the set of favorite elements. If yes then print "YES" (without the quotes). But if there exists a pair $ (x,y) $ from the given set that Limak wouldn't be able to succeed then you should print "NO" (without the quotes).

输入输出格式

输入格式


The first line contains three integers $ n $ , $ m $ and $ q $ ( $ 1<=n,q<=300000,0<=m<=300000 $ ) — the number of elements, the number of Limak's machines and the number of gossips, respectively. Each of the next $ m $ lines contains two integers $ a_{i} $ and $ b_{i} $ ( $ 1<=a_{i},b_{i}<=n $ ) describing one of Limak's machines. Then, the description of $ q $ gossips follows. The first line of the description of the $ i $ -th gossip contains two integers $ n_{i} $ and $ m_{i} $ ( $ 1<=n_{i}<=300000,0<=m_{i}<=300000 $ ). The second line contains $ n_{i} $ distinct integers $ x_{i,1},x_{i,2},...,x_{i,ni} $ ( $ 1<=x_{i,j}<=n $ ) — Radewoosh's favorite elements in the $ i $ -th gossip. Note that $ n_{i}=1 $ is allowed, in this case there are no pairs of distinct elements, so Limak automatically wins (the answer is "YES"). Then $ m_{i} $ lines follow, each containing two integers $ a_{i,j},b_{i,j} $ ( $ 1<=a_{i,j},b_{i,j} $ ) describing one of Radewoosh's machines in the $ i $ -th gossip. The sum of $ n_{i} $ over all gossips won't exceed $ 300000 $ . Also, the sum of $ m_{i} $ over all gossips won't exceed $ 300000 $ . Important: Because we want you to process the gossips online, in order to know the elements in Radewoosh's favorite set and elements that his machines can transform, for on each number that denotes them in the input you should use following function: ```cpp int rotate(int element) { element=(element+R)%n; if (element==0) { element=n; } return element; } ``` where $ R $ is initially equal to $ 0 $ and is increased by the number of the query any time the answer is "YES". Queries are numbered starting with $ 1 $ in the order they appear in the input.

输出格式


You should print $ q $ lines. The $ i $ -th of them should contain "YES" (without quotes) if for the $ i $ -th gossip for each pair of elements $ x $ and $ y $ (in the set $ x_{i,1},x_{i,2},...,x_{i,ni} $ ) Limak is able to succeed. Otherwise you should print "NO" (without quotes).

输入输出样例

输入样例 #1

6 5 4
1 2
2 3
3 4
2 4
5 6
2 0
4 2
2 1
6 2
3 4
3 2
6 3 4
2 5
4 6
2 1
1 2
1 2

输出样例 #1

YES
NO
YES
YES

输入样例 #2

7 6 2
1 2
1 3
2 4
2 5
3 6
3 7
7 2
1 2 3 4 5 6 7
4 5
6 7
7 2
1 2 3 4 5 6 7
4 6
5 7

输出样例 #2

NO
YES

说明

Lets look at first sample: In first gossip Radewoosh's favorite set is $ {4,2} $ and he has no machines. Limak can tranform element $ 4 $ into $ 2 $ (so half of a task is complete) and then $ 2 $ into $ 3 $ , and $ 3 $ into $ 4 $ . Answer is "YES", so $ R $ is increased by $ 1 $ . In second gossip set in the input is denoted by $ {6,2} $ and machine by $ (3,4) $ , but $ R $ is equal to $ 1 $ , so set is $ {1,3} $ and machine is $ (4,5) $ . Answer is "NO", so $ R $ isn't changed. In third gossip set $ {6,4,3} $ and machines $ (2,5) $ and $ (4,6) $ are deciphered to be $ {1,5,4} $ , $ (3,6) $ and $ (5,1) $ . Consider Radewoosh's choices: - If he chooses elements $ 1 $ and $ 5 $ , then Limak is able to transform $ 1 $ into $ 5 $ , then $ 6 $ into $ 3 $ , $ 3 $ into $ 2 $ and $ 2 $ into $ 1 $ . - If he chooses elements $ 5 $ and $ 4 $ , then Limak is able to transform $ 5 $ into $ 6 $ , $ 6 $ into $ 3 $ , $ 3 $ into $ 4 $ (half way already behind him), $ 4 $ into $ 2 $ , $ 2 $ into $ 1 $ , $ 1 $ into $ 5 $ . - If he chooses elements $ 1 $ and $ 4 $ , then Limak is able to transform $ 1 $ into $ 2 $ , $ 2 $ into $ 4 $ , $ 4 $ into $ 3 $ , $ 3 $ into $ 6 $ , $ 6 $ into $ 5 $ and $ 5 $ into $ 1 $ . So Limak is able to execute task. Answer is "YES" and $ R $ is increased by $ 3 $ (it's equal to $ 4 $ now). In last gossip $ {1,2} $ and $ (1,2) $ are deciphered to be $ {5,6} $ and $ (5,6) $ . Now there are $ 2 $ machines $ (5,6) $ so Limak is able to execute task again.