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<iostream>
#include<cmath>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<queue>
#define fs(i,x,y) for(int i=(x),_=(y);i<=_;++i)
#define fn(i,x,y) for(int i=(x),_=(y);i>=_;--i)
#define tor(i,v,x) for(int i=head[x],v=to[i];i;i=nxt[i],v=to[i])
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define mpi(x,y) make_pair(x,y)
#define pi pair<int,int>
//#define int ll
#define DEBUG printf("%s %d\n",__FUNCTION__,__LINE__)
using namespace std;
typedef long long ll;
typedef double db;
template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=4e5+7,P=998244353;
int n,m,q;
int bcj[N],col[N],odd[N],to[N],sum[N][2],fac=1;
int ans,tot;
//注意ll的问题，在计算hash的时候可能爆炸

void add(int &x,int y){x+=y;if(x>=P)x-=P;}

int find(int x){
	if(!(x^bcj[x]))return x;
	int y=bcj[x],anc=find(y);
	col[x]^=col[y];bcj[x]=anc;return anc;
}

void merge(int x,int y){
	add(fac,fac);++tot;bcj[tot]=tot;
	if(odd[x]<odd[y])swap(x,y);
	if(!odd[x]){
		odd[x]^=1;odd[y]^=1;to[x]=to[y]=tot;sum[tot][0]=fac;return;
	}
	if(!odd[y]){//x奇 y偶
		odd[x]^=1;odd[y]^=1;
		int w=to[x],rt=find(w);to[x]=0,to[y]=tot;col[tot]=col[w]^1;
		bcj[tot]=rt;add(sum[rt][col[tot]],fac);//用来处理颜色反转的
		if(col[tot])add(ans,fac);
		return;
	}//全奇
	odd[x]^=1;odd[y]^=1;int w1=to[x],w2=to[y];to[x]=to[y]=0;
	int rt1=find(w1),rt2=find(w2);
	col[tot]=col[w1]^1;bcj[tot]=rt1;
	add(sum[rt1][col[tot]],fac);if(col[tot])add(ans,fac);
	if(rt1==rt2)return;
	bcj[rt2]=rt1;col[rt2]=col[w1]^col[w2];
	add(sum[rt1][0],sum[rt2][col[rt2]]);add(sum[rt1][1],sum[rt2][col[rt2]^1]);
	if(col[rt2])add(ans,sum[rt2][0]),add(ans,P-sum[rt2][1]);
}

signed main(){
	read(n);read(m);read(q);
	while(q--){
		int x,y;read(x);read(y);merge(x,y+n);
	}
	read(q);
	while(q--){
		int opt;read(opt);
		if(opt==1){
			int x,y;read(x);read(y);merge(x,y+n);
			cout<<ans<<endl;
		}else{
			vector<int>wt;
			fs(i,1,tot){
				find(i);if(col[i])wt.push_back(i);
			}
			cout<<wt.size()<<' ';for(auto v:wt)cout<<v<<' ';cout<<endl;
		}
	}
	return 0;
}