Problem: You are given a bipartite graph consisting of n_1 vertices in the first part, n_2 vertices in the second part, and m edges, numbered from 1 to m. You have to color each edge into one of two colors, red and blue. You have to minimize the following value: ∑ _{v ∈ V} |r(v) - b(v)|, where V is the set of vertices of the graph, r(v) is the number of red edges incident to v, and b(v) is the number of blue edges incident to v.

Sounds classical and easy, right? Well, you have to process q queries of the following format:

  * 1 v_1 v_2 — add a new edge connecting the vertex v_1 of the first part with the vertex v_2 of the second part. This edge gets a new index as follows: the first added edge gets the index m + 1, the second — m + 2, and so on. After adding the edge, you have to print the hash of the current optimal coloring (if there are multiple optimal colorings, print the hash of any of them). Actually, this hash won't be verified, you may print any number as the answer to this query, but you may be asked to produce the coloring having this hash; 
  * 2 — print the optimal coloring of the graph with the same hash you printed while processing the previous query. The query of this type will only be asked after a query of type 1, and there will be at most 10 queries of this type. If there are multiple optimal colorings corresponding to this hash, print any of them. 



Note that if an edge was red or blue in some coloring, it may change its color in next colorings.

The hash of the coloring is calculated as follows: let R be the set of indices of red edges, then the hash is (∑ _{i ∈ R} 2^i) mod 998244353.

Note that you should solve the problem in online mode. It means that you can't read the whole input at once. You can read each query only after writing the answer for the last query. Use functions fflush in C++ and BufferedWriter.flush in Java languages after each writing in your program.

Input

The first line contains three integers n_1, n_2 and m (1 ≤ n_1, n_2, m ≤ 2 ⋅ 10^5).

Then m lines follow, the i-th of them contains two integers x_i and y_i (1 ≤ x_i ≤ n_1; 1 ≤ y_i ≤ n_2) meaning that the i-th edge connects the vertex x_i from the first part and the vertex y_i from the second part.

The next line contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries you have to process.

The next q lines contain the queries in the format introduced in the statement.

Additional constraints on the input:

  * at any moment, the graph won't contain any multiple edges; 
  * the queries of type 2 are only asked if the previous query had type 1; 
  * there are at most 10 queries of type 2. 

Output

To answer a query of type 1, print one integer — the hash of the optimal coloring.

To answer a query of type 2, print one line. It should begin with the integer k — the number of red edges. Then, k distinct integer should follow — the indices of red edges in your coloring, in any order. Each index should correspond to an existing edge, and the hash of the coloring you produce should be equal to the hash you printed as the answer to the previous query.

If there are multiple answers to a query, you may print any of them.

Example

Input


3 4 2
1 2
3 4
10
1 1 3
1 2 3
2
1 3 3
2
1 2 4
2
1 2 1
1 1 1
2


Output


8
8
1 3
40
2 3 5
104
3 5 6 3
104
360
4 5 6 3 8

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int mod=998244353;
const int maxn=(4e5)+10;
int n1,n2,m,deg[maxn],q;
int ans,mi[maxn];
vector<int> res;
vector<deque<int> > cyc,path;
int id[maxn],bg[maxn],ed[maxn];
int haxi[maxn][2];
void update(int &x,int y) { x+=y; if (x>=mod) x-=mod; }
void add(int x,int y,int now) {
	if (!deg[x]&&!deg[y]) {
		int cur=id[x]=id[y]=(int)path.size();
		bg[cur]=x,ed[cur]=y;
		path.push_back({now});
		haxi[cur][0]=mi[now];
		haxi[cur][1]=0;
	} else {
		if (deg[x]) swap(x,y);
		if (!deg[x]) {
			int cur=id[x]=id[y];
			update(ans,mod-haxi[cur][1]);
			//if (m==21) printf("%d %d %d %d %d\n",x,y,deg[x],deg[y],ans);
			if (y==ed[cur]) {
				update(haxi[cur][(int)path[cur].size()&1],mi[now]);
				path[cur].push_back(now); ed[cur]=x;
			} else {
				path[cur].push_front(now);
				swap(haxi[cur][0],haxi[cur][1]);
				update(haxi[cur][0],mi[now]);
				bg[cur]=x;
			}
			id[y]=-1;
			update(ans,haxi[cur][1]);
		} else {
			//if (m==22) printf("%d %d %d %d %d %d %d\n",x,y,id[x],id[y],deg[x],deg[y],ans);
			if (id[x]==id[y]) {
				int cur=id[x];
				cyc.push_back(path[cur]);
				update(ans,mod-haxi[cur][1]);
				update(haxi[cur][(int)path[cur].size()&1],mi[now]);
				update(ans,haxi[cur][1]);
				cyc.back().push_back(now);
				path[cur].clear();
				id[x]=id[y]=-1;
			} else {
				if ((int)path[id[x]].size()<(int)path[id[y]].size()) swap(x,y);
				update(ans,mod-haxi[id[y]][1]);
				if (bg[id[y]]!=y) reverse(path[id[y]].begin(),path[id[y]].end()),swap(bg[id[y]],ed[id[y]]);
				int cur=id[x];
				update(ans,mod-haxi[id[x]][1]);
				if (x==bg[cur]) {
					path[cur].push_front(now);
					swap(haxi[cur][0],haxi[cur][1]);
					update(haxi[cur][0],mi[now]);
					for (int v : path[id[y]]) {
						path[cur].push_front(v);
						swap(haxi[cur][0],haxi[cur][1]);
						update(haxi[cur][0],mi[v]);
					}
					bg[cur]=ed[id[y]];
				} else {
					update(haxi[cur][(int)path[cur].size()&1],mi[now]);
					path[cur].push_back(now);
					for (int v : path[id[y]]) {
						update(haxi[cur][(int)path[cur].size()&1],mi[v]);
						path[cur].push_back(v);
					}
					ed[cur]=ed[id[y]];
					//printf("OK %d %d\n",ans,haxi[cur][1]);
				}
				update(ans,haxi[cur][1]);
				id[ed[id[y]]]=cur;
				path[id[y]].clear();
				id[x]=id[y]=-1;
			}
		}
	}
	deg[x]^=1,deg[y]^=1;
}
int main() {
	//freopen("1.txt","r",stdin);
	memset(id,-1,sizeof(id)); mi[0]=1;
	for (int i=1;i<maxn;i++) mi[i]=(mi[i-1]<<1)%mod;
	read(n1),read(n2),read(m);
	int x,y,op;
	for (int i=1;i<=m;i++) {
		read(x),read(y); y+=n1;
		add(x,y,i);
	}
	//printf("%d\n",ans);
	read(q);
	while (q--) {
		read(op);
		if (op==1) {
			read(x),read(y); y+=n1;
			m++; add(x,y,m);
			printf("%d\n",ans);
		} else {
			res.clear();
			for (deque<int> A : cyc) for (int i=0;i<A.size();i++) if (i&1) res.push_back(A[i]);
			for (deque<int> A : path) for (int i=0;i<A.size();i++) if (i&1) res.push_back(A[i]);
			printf("%d ",(int)res.size());
			for (int x : res) printf("%d ",x); puts("");
		}
		fflush(stdout);
	}
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Integer overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/