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 <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXSIDE = 200000;
const int MAXN = MAXSIDE + MAXSIDE;
const int MAXMINIT = 200000;
const int MAXQ = 200000;
const int MAXM = MAXMINIT + MAXQ;
const int MOD = 998244353;
void inc(int& a, int b) { if ((a += b) >= MOD) a -= MOD; }
void dec(int& a, int b) { inc(a, MOD - b); }
struct Path { 
	bool alive; int start, end, evensum, oddsum; mutable deque<int> edges; mutable bool revedges; 
	void reverse() { swap(start, end); revedges = !revedges; if (SZ(edges) % 2 == 0) swap(evensum, oddsum); }
	void normalize() const { if (revedges) { revedges = !revedges; std::reverse(edges.begin(), edges.end()); } }
};

int na, nb;
int anshash;
vector<int> ans;

int n, m;
int endpoint[MAXN];
vector<Path> paths;
vector<Path> cycles;
int w[MAXM];

void appendedge(Path& p, int id) {
	if (SZ(p.edges) % 2 == 0) inc(p.evensum, w[id]); else inc(p.oddsum, w[id]);
	if (!p.revedges) p.edges.push_back(id); else p.edges.push_front(id);
}
void appendpath(Path& p, const Path& q) {
	q.normalize();
	for (int id : q.edges) appendedge(p, id);
}

void init() {
	n = na + nb;
	m = 0;
	REP(i, n) endpoint[i] = -1;
	anshash = 0;
	paths.clear();
	cycles.clear();
}
void addedge(int a, int b) {
	int id = m++;
	w[id] = id == 0 ? 2 : 2 * w[id - 1] % MOD;
	b += na;
	if (endpoint[a] == -1 && endpoint[b] == -1) {
		Path p; p.alive = true; p.start = a; p.end = b; p.evensum = p.oddsum = 0; p.edges.clear(); p.revedges = false; appendedge(p, id);
		int pid = SZ(paths); paths.PB(p);
		endpoint[a] = endpoint[b] = pid;
		inc(anshash, p.evensum);
	} else if (endpoint[a] == -1 || endpoint[b] == -1) {
		if (endpoint[a] == -1) swap(a, b);
		int pid = endpoint[a];
		Path& p = paths[pid];
		dec(anshash, p.evensum);
		if (p.end != a) p.reverse();
		appendedge(p, id);
		p.end = b;
		endpoint[a] = -1, endpoint[b] = pid;
		inc(anshash, p.evensum);
	} else if (endpoint[a] != endpoint[b]) {
		int pida = endpoint[a], pidb = endpoint[b];
		if (SZ(paths[pida].edges) < SZ(paths[pidb].edges)) swap(a, b), swap(pida, pidb);
		Path& pa = paths[pida], & pb = paths[pidb];
		dec(anshash, pa.evensum);
		dec(anshash, pb.evensum);
		if (pa.end != a) pa.reverse();
		if (pb.start != b) pb.reverse();
		appendedge(pa, id);
		appendpath(pa, pb);
		pa.end = pb.end;
		pb.alive = false;
		endpoint[a] = endpoint[b] = -1;
		endpoint[pa.end] = pida;
		inc(anshash, pa.evensum);
	} else {
		int pid = endpoint[a];
		Path& p = paths[pid];
		dec(anshash, p.evensum);
		if (p.end != b) p.reverse();
		assert(a == p.start && b == p.end && SZ(p.edges) % 2 == 1);
		appendedge(p, id);
		p.end = a;
		cycles.PB(p);
		endpoint[a] = endpoint[b] = -1;
		inc(anshash, p.evensum);
		p.alive = false;
	}
	//printf("endpoint:"); REP(i, n) printf(" %d", endpoint[i]); puts("");
	//for (const Path& p : paths) if (p.alive) { p.normalize(); printf("path %d->%d [%d vs %d]:", p.start + 1, p.end + 1, p.evensum, p.oddsum); for (int id : p.edges) printf(" %d", id + 1); puts(""); }
	//for (const Path& p : cycles) if (p.alive) { p.normalize(); printf("cycle %d->%d [%d vs %d]:", p.start + 1, p.end + 1, p.evensum, p.oddsum); for (int id : p.edges) printf(" %d", id + 1); puts(""); }
}
void reconstruct() {
	ans.clear();
	for (const Path& p : paths) if (p.alive) { p.normalize(); bool take = true; for (int id : p.edges) { if (take) ans.PB(id); take = !take; } }
	for (const Path& p : cycles) if (p.alive) { p.normalize(); bool take = true; for (int id : p.edges) { if (take) ans.PB(id); take = !take; } }
}

void run() {
	int minit;
	scanf("%d%d%d", &na, &nb, &minit);
	init();
	REP(i, minit) {
		int a, b; scanf("%d%d", &a, &b); --a, --b;
		addedge(a, b); 
	}
	int nq;
	scanf("%d", &nq);
	REP(i, nq) {
		int kind; scanf("%d", &kind);
		if (kind == 1) {
			int a, b; scanf("%d%d", &a, &b); --a, --b;
			addedge(a, b);
			printf("%d\n", anshash); fflush(stdout);
		}
		if (kind == 2) {
			reconstruct();
			printf("%d", SZ(ans)); REPSZ(j, ans) printf(" %d", ans[j] + 1); puts(""); fflush(stdout);
		}
	}
}


int main() {
	//int ncase; scanf("%d", &ncase); FORE(i, 1, ncase)
	run();
	return 0;
}