The first line of the input contains a single integer T
(1≤T≤10
), denoting the number of test cases.
For each of the next T
cases, the first line contains three space-separated integers n
, m
, q
(1≤n,m,q≤3⋅105
), denoting the number of service spots, number of running trails in the initial plan, and the number of queries.
In the next m
lines, the i
-th line contains two space-separated integers ui
, vi
(1≤ui,vi≤n
, ui≠vi
).
Each of the next q
lines contains two space-separated integers l′
, r′
(1≤l′≤r′≤m
). l
and r
can be calculated via the following procedure.
-
Let lastans denote the answer to the last query (if the answer is ''Yes'', lastans=1, otherwise lastans=0) and is initially zero.
-
k1=(l′xorlastans)modm+1.
-
k2=(r′xorlastans)modm+1.
-
l=min(k1,k2).
-
r=max(k1,k2).
l
and r
means the edges in [l,r]
will be chosen. That means, for this query, only edges (ul,vl),(ul+1,vl+1),…,(ur,vr)
are visible.
It is guaranteed that ∑n,∑m≤1.5⋅106
.