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<vector>
using namespace std;
const long long mod=998244353;
int N1,N2,M;
int pr[4<<17],hs[4<<17],hn[4<<17],pe[4<<17],pc[4<<17];
int ai[4<<17][2];
int ans,eh=1,id;
vector<int>es;
bool usd[4<<17];
void adj(int ei,vector<int>&a,int j)
{
	int pei=-1;
	int cnt=0;
	while(ei!=-1)
	{
		usd[ei]=true;
		if(cnt==j)a.push_back(ei);
		int tei=ei;
		if(pei==ai[ei][0])ei=ai[ei][1];
		else ei=ai[ei][0];
		pei=tei;
		cnt=1-cnt;
	}
}
void add(int ei,int ni)
{
	if(ai[ei][0]==-1)ai[ei][0]=ni;
	else ai[ei][1]=ni;
}
void add_edge(int u,int v)
{
	id++;
	ai[id][0]=ai[id][1]=-1;
	v+=N1;
	eh=eh*2%mod;
	if(pr[u]!=-1)
	{
		if(pr[v]!=-1)
		{
			if(pr[v]==u&&pr[u]==v)
			{
				if(pc[u]==0)
				{
					adj(pe[u],es,0);
				}
				else
				{
					es.push_back(id);
					adj(pe[u],es,1);
					ans=(ans+eh)%mod;
				}
			}
			else
			{
				if(pc[u]!=pc[v])
				{
					int rv=pr[v];
					pc[v]=1-pc[v];
					pc[rv]=1-pc[rv];
					ans=(ans+mod-hn[v])%mod;
					hn[v]=hn[rv]=(hs[v]-hn[v]+mod)%mod;
					ans=(ans+hn[v])%mod;
				}
				int ru=pr[u],rv=pr[v];
				pr[ru]=rv;pr[rv]=ru;
				hs[ru]=hs[rv]=((hs[ru]+hs[rv])%mod+eh)%mod;
				hn[ru]=hn[rv]=(hn[ru]+hn[rv])%mod;
				if(pc[u]==1)
				{
					hn[ru]=hn[rv]=(hn[ru]+eh)%mod;
					ans=(ans+eh)%mod;
				}
				add(pe[u],id);
				add(id,pe[u]);
				add(pe[v],id);
				add(id,pe[v]);
			}
			pr[u]=pr[v]=-1;
		}
		else
		{
			int ru=pr[u];
			pr[ru]=v;
			hs[ru]=(hs[ru]+eh)%mod;
			if(pc[u]==1)
			{
				hn[ru]=(hn[ru]+eh)%mod;
				ans=(ans+eh)%mod;
			}
			pr[u]=-1;
			pr[v]=ru;
			hs[v]=hs[ru];
			hn[v]=hn[ru];
			pe[v]=id;
			pc[v]=1-pc[u];
			add(pe[u],id);
			add(id,pe[u]);
		}
	}
	else
	{
		if(pr[v]!=-1)
		{
			int rv=pr[v];
			pr[rv]=u;
			hs[rv]=(hs[rv]+eh)%mod;
			if(pc[v]==1)
			{
				hn[rv]=(hn[rv]+eh)%mod;
				ans=(ans+eh)%mod;
			}
			pr[v]=-1;
			pr[u]=rv;
			hs[u]=hs[rv];
			hn[u]=hn[rv];
			pe[u]=id;
			pc[u]=1-pc[v];
			add(pe[v],id);
			add(id,pe[v]);
		}
		else
		{
			pr[u]=v;
			pr[v]=u;
			hs[u]=hs[v]=eh;
			hn[u]=hn[v]=eh;
			pe[u]=pe[v]=id;
			pc[u]=pc[v]=0;
			ans=(ans+eh)%mod;
		}
	}
}
int main()
{
	scanf("%d%d%d",&N1,&N2,&M);
	for(int i=0;i<N1+N2;i++)pr[i]=-1;
	for(int i=0;i<M;i++)
	{
		int u,v;scanf("%d%d",&u,&v);
		u--,v--;
		add_edge(u,v);
	}
	int Q;
	scanf("%d",&Q);
	for(int ccc=0;ccc<Q;ccc++)
	{
		int t;scanf("%d",&t);
		if(t==1)
		{
			int u,v;scanf("%d%d",&u,&v);
			u--,v--;
			add_edge(u,v);
			printf("%d\n",ans);
		}
		else
		{
			vector<int>ret=es;
			for(int i=0;i<=id;i++)usd[i]=false;
			for(int i=0;i<N1+N2;i++)if(pr[i]!=-1&&!usd[pe[i]])
			{
				adj(pe[i],ret,pc[i]);
			}
			printf("%d",ret.size());
			for(int id:ret)printf(" %d",id);
			puts("");
		}
		fflush(stdout);
	}
}