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 long long ll;
const int mod=998244353;
int deg[400010],id[400010];
ll pw2=2,ans=0;
deque<int> cur;
vector<deque<int> > ring;
struct Chain
{
	int head,tail;
	ll val[2];
	deque<int> que;
	Chain(int u,int v,int x,ll y)
	{
		head=u;tail=v;
		que.push_back(x);
		val[0]=0;val[1]=y;
	}
};
vector<Chain> chain;
void solve(int u,int v,int w)
{
	if(deg[v]&1) swap(u,v);
	if(deg[u]&1 && deg[v]&1)
	{
		int x=id[u],y=id[v],l1=chain[x].que.size(),l2=chain[y].que.size();
		if(x==y)
		{
			for(int i=0;i<l1;i++,chain[x].que.pop_front())
				cur.push_back(chain[x].que.front());
			cur.push_back(w);
			ring.push_back(cur);cur.clear();
		}
		else
		{
			if(l1<l2) swap(u,v),swap(x,y),swap(l1,l2);
			(ans+=mod-chain[x].val[1]+mod-chain[y].val[1])%=mod;
			if(chain[x].head==u)
			{
				(chain[x].val[0]+=pw2)%=mod;
				chain[x].que.push_front(w);
				if(chain[y].head==v)
				{
					chain[x].head=chain[y].tail;
					(chain[x].val[0]+=chain[y].val[0])%=mod;
					(chain[x].val[1]+=chain[y].val[1])%=mod;
					for(int i=0;i<l2;i++,chain[y].que.pop_front())
						chain[x].que.push_front(chain[y].que.front());
				}
				else
				{
					chain[x].head=chain[y].head;
					(chain[x].val[0]+=chain[y].val[(l2-1)&1])%=mod;
					(chain[x].val[1]+=chain[y].val[l2&1])%=mod;
					for(int i=0;i<l2;i++,chain[y].que.pop_back())
						chain[x].que.push_front(chain[y].que.back());
				}
				if((l2+1)&1) swap(chain[x].val[0],chain[x].val[1]);
			}
			else
			{
				(chain[x].val[(l1+1)&1]+=pw2)%=mod;
				chain[x].que.push_back(w);
				if(chain[y].head==v)
				{
					chain[x].tail=chain[y].tail;
					(chain[x].val[l1&1]+=chain[y].val[1])%=mod;
					(chain[x].val[(l1+1)&1]+=chain[y].val[0])%=mod;
					for(int i=0;i<l2;i++,chain[y].que.pop_front())
						chain[x].que.push_back(chain[y].que.front());
				}
				else
				{
					chain[x].tail=chain[y].head;
					(chain[x].val[l1&1]+=chain[y].val[l2&1])%=mod;
					(chain[x].val[(l1+1)&1]+=chain[y].val[(l2-1)&1])%=mod;
					for(int i=0;i<l2;i++,chain[y].que.pop_back())
						chain[x].que.push_back(chain[y].que.back());
				}
			}
			(ans+=chain[x].val[1])%=mod;
			id[chain[x].head]=id[chain[x].tail]=x;
		}
	}
	else if(deg[u]&1)
	{
		int x=id[v]=id[u];
		(ans+=mod-chain[x].val[1])%=mod;
		if(chain[x].head==u)
		{
			chain[x].head=v;
			chain[x].que.push_front(w);
			swap(chain[x].val[0],chain[x].val[1]);
			(chain[x].val[1]+=pw2)%=mod;
		}
		else
		{
			chain[x].tail=v;
			chain[x].que.push_back(w);
			(chain[x].val[chain[x].que.size()&1]+=pw2)%=mod;
		}
		(ans+=chain[x].val[1])%=mod;
	}
	else
	{
		chain.push_back(Chain(u,v,w,pw2));
		id[u]=id[v]=chain.size()-1;
		(ans+=pw2)%=mod;
	}
	deg[u]++;deg[v]++;
}
int main()
{
	int n1,n2,m,q,u,v,op;
	cin>>n1>>n2>>m;
	for(int i=1;i<=m;i++,pw2=pw2*2%mod)
	{
		scanf("%d%d",&u,&v);
		solve(u,v+n1,i);
	}
	cin>>q;
	while(q--)
	{
		scanf("%d",&op);
		if(op==1)
		{
			scanf("%d%d",&u,&v);
			solve(u,v+n1,++m);pw2=pw2*2%mod;
			cout<<ans<<endl<<flush;
		}
		else
		{
			int cnt=0;
			for(int i=0,sz=chain.size();i<sz;i++) cnt+=(chain[i].que.size()+1)/2;
			for(int i=0,sz=ring.size();i<sz;i++) cnt+=ring[i].size()/2;
			printf("%d",cnt);
			for(int i=0,s1=chain.size();i<s1;i++)
				for(int j=0,s2=chain[i].que.size();j*2<s2;j++)
					printf(" %d",chain[i].que[j*2]);
			for(int i=0,s1=ring.size();i<s1;i++)
				for(int j=0,s2=ring[i].size();j*2<s2;j++)
					printf(" %d",ring[i][j*2]);
			cout<<endl<<flush;
		}
	}
	return 0;
}