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 <cstdio>
#include <cassert>
#include <algorithm>
const int Maxn=400000;
const int Mod=998244353;
namespace DSU{
	int sum[Maxn+5][2];
	int fa[Maxn+5],val[Maxn+5];
	void init(){
		sum[0][1]=1;
		for(int i=1;i<=Maxn;i++){
			fa[i]=i;
			sum[i][1]=(sum[i-1][1]<<1)%Mod;
		}
	}
	int find(int x){
		if(x==fa[x]){
			return x;
		}
		int y=fa[x],t=find(fa[x]);
		val[x]^=val[y];
		return fa[x]=t;
	}
	void merge(int x,int y,int a){
		int fa_x=find(x),fa_y=find(y);
		assert(fa_x!=fa_y);
		fa[fa_y]=fa_x;
		val[fa_y]=val[x]^val[y]^a;
		sum[fa_x][0]=(sum[fa_x][0]+sum[fa_y][val[fa_y]])%Mod;
		sum[fa_x][1]=(sum[fa_x][1]+sum[fa_y][val[fa_y]^1])%Mod;
	}
	int find_val(int x){
		return sum[find(x)][0];
	}
	int find_node(int x){
		find(x);
		return val[x];
	}
}
int deg[Maxn+5];
int to_node[Maxn+5],to_edge[Maxn+5];
int id_tot;
int ans;
void link(int u,int v){
	id_tot++;
	if(deg[u]<deg[v]){
		std::swap(u,v);
	}
	if(deg[u]==0){
		deg[u]^=1,deg[v]^=1;
		to_node[u]=v,to_node[v]=u;
		to_edge[u]=to_edge[v]=id_tot;
		ans=(ans+DSU::find_val(id_tot))%Mod;
		return;
	}
	if(deg[v]==0){
		deg[u]^=1,deg[v]^=1;
		int t=to_node[u],w=to_edge[u];
		to_node[t]=v,to_node[v]=t;
		to_edge[v]=id_tot;
		ans=(ans-DSU::find_val(w)+Mod)%Mod;
		DSU::merge(w,id_tot,1);
		ans=(ans+DSU::find_val(w))%Mod;
		return;
	}
	deg[u]^=1,deg[v]^=1;
	if(to_node[u]==v){
		int w=to_edge[u];
		ans=(ans-DSU::find_val(w)+Mod)%Mod;
		DSU::merge(w,id_tot,1);
		ans=(ans+DSU::find_val(w))%Mod;
		return;
	}
	int t_u=to_node[u],t_v=to_node[v];
	to_node[t_u]=t_v,to_node[t_v]=t_u;
	int w_1=to_edge[u],w_2=to_edge[v];
	ans=(ans-DSU::find_val(w_1)+Mod)%Mod;
	ans=(ans-DSU::find_val(w_2)+Mod)%Mod;
	DSU::merge(w_1,id_tot,1);
	DSU::merge(w_1,w_2,0);
	ans=(ans+DSU::find_val(w_1))%Mod;
}
int lis[Maxn+5],lis_len;
int main(){
	DSU::init();
	int n_1,n_2,m;
	scanf("%d%d%d",&n_1,&n_2,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		link(u,v+n_1);
	}
	int q;
	scanf("%d",&q);
	for(int t=1;t<=q;t++){
		int op;
		scanf("%d",&op);
		if(op==1){
			int u,v;
			scanf("%d%d",&u,&v);
			link(u,v+n_1);
			printf("%d\n",ans);
		}
		else{
			lis_len=0;
			for(int i=1;i<=id_tot;i++){
				if(DSU::find_node(i)==1){
					lis[++lis_len]=i;
				}
			}
			printf("%d ",lis_len);
			for(int i=1;i<=lis_len;i++){
				printf("%d ",lis[i]);
			}
			puts("");
		}
		fflush(stdout);
	}
	return 0;
}