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;
const int mod=998244353;
int pw2[400010],lnk[400010],ans,tot,tot2;
bool deg[400010];
struct node
{
	deque<int> que;
	int red,blue,front,back;
	void push_back(int w)
	{
		if(que.size()&1) (blue+=pw2[w])%=mod;
		else (red+=pw2[w])%=mod;
		que.push_back(w);
	}
	void push_front(int w)
	{
		swap(blue,red);
		(red+=pw2[w])%=mod;
		que.push_front(w);
	}
}lnks[400010];
deque<int> rings[400010];
int merge(int x,int y,int u)
{
	if(lnks[x].que.size()<lnks[y].que.size()) swap(x,y);
	if(lnks[x].back==u)
		if(lnks[y].front==u)
		{
			while(!lnks[y].que.empty())
			{
				lnks[x].push_back(lnks[y].que.front());
				lnks[y].que.pop_front();
			}
			lnks[x].back=lnks[y].back;
			lnk[lnks[x].back]=x;
		}
		else
		{
			while(!lnks[y].que.empty())
			{
				lnks[x].push_back(lnks[y].que.back());
				lnks[y].que.pop_back();
			}
			lnks[x].back=lnks[y].front;
			lnk[lnks[x].back]=x;
		}
	else
		if(lnks[y].back==u)
		{
			while(!lnks[y].que.empty())
			{
				lnks[x].push_front(lnks[y].que.back());
				lnks[y].que.pop_back();
			}
			lnks[x].front=lnks[y].front;
			lnk[lnks[x].front]=x;
		}
		else
		{
			while(!lnks[y].que.empty())
			{
				lnks[x].push_front(lnks[y].que.front());
				lnks[y].que.pop_front();
			}
			lnks[x].front=lnks[y].back;
			lnk[lnks[x].front]=x;
		}
	return x;
}
void addedge(int u,int v,int w)
{
	if(deg[u] && deg[v])
	{
		if(lnk[u]!=lnk[v])
		{
			(ans+=mod-lnks[lnk[u]].red)%=mod;
			(ans+=mod-lnks[lnk[v]].red)%=mod;
			if(lnks[lnk[u]].front==u) lnks[lnk[u]].push_front(w),lnks[lnk[u]].front=v;
			else lnks[lnk[u]].push_back(w),lnks[lnk[u]].back=v;
			(ans+=lnks[merge(lnk[u],lnk[v],v)].red)%=mod;
		}
		else
		{
			(ans+=mod-lnks[lnk[u]].red)%=mod;
			if(lnks[lnk[u]].front==u) lnks[lnk[u]].push_front(w);
			else lnks[lnk[u]].push_back(w);
			(ans+=lnks[lnk[u]].red)%=mod;
			rings[++tot2]=lnks[lnk[u]].que;
			while(!lnks[lnk[u]].que.empty()) lnks[lnk[u]].que.pop_back();
		}
		deg[u]=deg[v]=0;
	}
	else if(!deg[u] && deg[v])
	{
		(ans+=mod-lnks[lnk[v]].red)%=mod;
		if(lnks[lnk[v]].front==v) lnks[lnk[v]].push_front(w),lnks[lnk[v]].front=u;
		else lnks[lnk[v]].push_back(w),lnks[lnk[v]].back=u;
		(ans+=lnks[lnk[v]].red)%=mod;
		lnk[u]=lnk[v];deg[u]=1;deg[v]=0;
	}
	else if(deg[u] && !deg[v])
	{
		(ans+=mod-lnks[lnk[u]].red)%=mod;
		if(lnks[lnk[u]].front==u) lnks[lnk[u]].push_front(w),lnks[lnk[u]].front=v;
		else lnks[lnk[u]].push_back(w),lnks[lnk[u]].back=v;
		(ans+=lnks[lnk[u]].red)%=mod;
		lnk[v]=lnk[u];deg[u]=0;deg[v]=1;
	}
	else
	{
		lnk[u]=lnk[v]=++tot;
		lnks[tot].front=u;lnks[tot].back=v;lnks[tot].que.push_back(w);
		lnks[tot].red=pw2[w];lnks[tot].blue=0;
		(ans+=(lnks[lnk[u]].red))%=mod;
		deg[u]=deg[v]=1;
	}
}
int main()
{
	pw2[0]=1;
	for(int i=1;i<=4e5;i++) pw2[i]=pw2[i-1]*2%mod;
	int n1,n2,m,q,u,v,op;
	cin>>n1>>n2>>m;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);v+=n1;
		addedge(u,v,i);
	}
	cin>>q;
	while(q--)
	{
		scanf("%d",&op);
		if(op==1)
		{
			m++;
			scanf("%d%d",&u,&v);v+=n1;
			addedge(u,v,m);
			printf("%d\n",ans);
			fflush(stdout);
		}
		else
		{
			int num=0;
			for(int i=1;i<=tot;i++) num+=(lnks[i].que.size()+1)/2;
			for(int i=1;i<=tot2;i++) num+=rings[i].size()/2;
			printf("%d ",num);
			for(int i=1;i<=tot;i++)
				for(int sz=lnks[i].que.size(),j=0;j<sz;j+=2)
					printf("%d ",lnks[i].que[j]);
			for(int i=1;i<=tot2;i++)
				for(int sz=rings[i].size(),j=0;j<sz;j+=2)
					printf("%d ",rings[i][j]);
			puts("");
			fflush(stdout);
		}
	}
	return 0;
}