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;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int A,B,M,Q;
deque<int> D[404040];
int U[404040],V[404040];
pair<int,int> E[404040]; //末尾と辺index
int col[404040];
ll p2[404040];
const ll mo=998244353;

ll ret=0;

void add(int i,int x,int y) {
	y+=200000;
	U[i]=x;
	V[i]=y;
	int k,r;
	if(E[x].first==y) {
		//connect
		k=E[x].second;
		col[i]=col[D[k][0]]^1;
		if(col[i]==1) ret+=p2[i];
		E[x]=E[y]={0,0};
	}
	else if(E[x].first&&E[y].first) {
		int ox=E[x].first;
		int oy=E[y].first;
		k=E[x].second;
		r=E[y].second;
		
		assert(U[k]==x||V[k]==x);
		assert(U[r]==y||V[r]==y);
		
		if(D[k].size()<=D[r].size()) {
			swap(k,r);
			swap(x,y);
			swap(ox,oy);
		}
		
		if(U[r]!=y) reverse(ALL(D[r]));
		
		if(U[k]==x) {
			int cur=col[D[k][0]];
			D[k].push_front(i);
			cur^=1;
			col[i]=cur;
			if(col[i]) ret+=p2[i];
			
			FORR(v,D[r]) {
				if(col[v]) ret-=p2[v];
				cur^=1;
				col[v]=cur;
				if(col[v]) ret+=p2[v];
				D[k].push_front(v);
			}
			U[k]=oy;
		}
		else {
			int cur=col[D[k].back()];
			D[k].push_back(i);
			cur^=1;
			col[i]=cur;
			if(col[i]) ret+=p2[i];
			
			FORR(v,D[r]) {
				if(col[v]) ret-=p2[v];
				cur^=1;
				col[v]=cur;
				if(col[v]) ret+=p2[v];
				D[k].push_back(v);
			}
			V[k]=oy;
		}
		E[x]=E[y]={0,0};
		E[ox]={oy,k};
		E[oy]={ox,k};
		assert((U[k]==ox&&V[k]==oy)||(U[k]==oy&&V[k]==ox));
		D[r].clear();
		
	}
	else if(E[x].first||E[y].first) {
		if(E[y].first) swap(x,y);
		int o=E[x].first;
		k=E[x].second;
		assert(U[k]==x||V[k]==x);
		if(U[k]==x) {
			r=D[k][0];
			col[i]=col[r]^1;
			if(col[i]) ret+=p2[i];
			D[k].push_front(i);
			U[k]=y;
			assert(V[k]==o);
		}
		else {
			r=D[k].back();
			col[i]=col[r]^1;
			if(col[i]) ret+=p2[i];
			D[k].push_back(i);
			V[k]=y;
			assert(U[k]==o);
		}
		E[o]={y,k};
		E[x]={0,0};
		E[y]={o,k};
	}
	else {
		D[i].push_back(i);
		E[x]={y,i};
		E[y]={x,i};
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	FOR(i,401010) {
		p2[i+1]=p2[i]*2%mo;
	}
	
	cin>>A>>B>>M;
	for(i=1;i<=M;i++) {
		cin>>x>>y;
		add(i,x,y);
	}
	cin>>Q;
	while(Q--) {
		cin>>i;
		if(i==1) {
			cin>>x>>y;
			M++;
			add(M,x,y);
			ret=(ret%mo+mo)%mo;
			cout<<ret<<endl;
		}
		else {
			int c=0;
			for(i=1;i<=M;i++) c+=col[i];
			cout<<c;
			for(i=1;i<=M;i++) if(col[i]) cout<<" "<<i;
			cout<<endl;
		}
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}