#include <stdio.h>
#include <string.h>

#define N	400000
#define M	400000
#define MD	998244353

int p2[M + 1];

void init() {
	int i;

	p2[0] = 1;
	for (i = 1; i <= M; i++)
		p2[i] = p2[i - 1] * 2 % MD;
}

int hh1[M], hh2[M], hh[N], mate[N], sz[N], hash; char red[M];

void add(int i, int j, int h) {
	int h1, h2;

	hh1[h] = hh2[h] = -1, h1 = hh[i], h2 = hh[j];
	if (h1 == -1 && h2 == -1)
		hh[i] = hh[j] = h, mate[i] = j, mate[j] = i, sz[i] = sz[j] = 1;
	else if (h1 == -1) {
		hh2[h] = h2, hh[i] = h, hh[j] = -1;
		if (hh1[h2] == -1)
			hh1[h2] = h;
		else
			hh2[h2] = h;
		j = mate[j];
		mate[i] = j, mate[j] = i, sz[i] = ++sz[j];
		if (!red[h2])
			red[h] = 1, hash = (hash + p2[h + 1]) % MD;
	} else if (h2 == -1) {
		hh1[h] = h1, hh[j] = h, hh[i] = -1;
		if (hh1[h1] == -1)
			hh1[h1] = h;
		else
			hh2[h1] = h;
		i = mate[i];
		mate[i] = j, mate[j] = i, sz[j] = ++sz[i];
		if (!red[h1])
			red[h] = 1, hash = (hash + p2[h + 1]) % MD;
	} else {
		if (mate[i] != j && red[h1] != red[h2]) {
			int p, h_, tmp;

			if (sz[i] < sz[j]) {
				for (p = -1, h_ = h1; h_ != -1; tmp = p, p = h_, h_ = tmp ^ hh1[h_] ^ hh2[h_])
					if (!red[h_])
						red[h_] = 1, hash = (hash + p2[h_ + 1]) % MD;
					else
						red[h_] = 0, hash = (hash - p2[h_ + 1] + MD) % MD;
			} else {
				for (p = -1, h_ = h2; h_ != -1; tmp = p, p = h_, h_ = tmp ^ hh1[h_] ^ hh2[h_])
					if (!red[h_])
						red[h_] = 1, hash = (hash + p2[h_ + 1]) % MD;
					else
						red[h_] = 0, hash = (hash - p2[h_ + 1] + MD) % MD;
			}
		}
		if (!red[h1])
			red[h] = 1, hash = (hash + p2[h + 1]) % MD;
		hh[i] = hh[j] = -1;
		if (mate[i] != j) {
			i = mate[i], j = mate[j];
			mate[i] = j, mate[j] = i, sz[i] = sz[j] = sz[i] + 1 + sz[j];
			hh1[h] = h1, hh2[h] = h2;
			if (hh1[h1] == -1)
				hh1[h1] = h;
			else
				hh2[h1] = h;
			if (hh1[h2] == -1)
				hh1[h2] = h;
			else
				hh2[h2] = h;
		}
	}
}

int main() {
	int n1, n2, m, q, h, i, j;

	init();
	scanf("%d%d%d", &n1, &n2, &m);
	memset(hh, -1, (n1 + n2) * sizeof *hh);
	for (h = 0; h < m; h++) {
		scanf("%d%d", &i, &j), i--, j--, j += n1;
		add(i, j, h);
	}
	scanf("%d", &q);
	while (q--) {
		int t;

		scanf("%d", &t);
		if (t == 1) {
			scanf("%d%d", &i, &j), i--, j--, j += n1;
			add(i, j, m++);
			printf("%d\n", hash), fflush(stdout);
		} else {
			int cnt;

			cnt = 0;
			for (h = 0; h < m; h++)
				if (red[h])
					cnt++;
			printf("%d", cnt);
			for (h = 0; h < m; h++)
				if (red[h])
					printf(" %d", h + 1);
			printf("\n"), fflush(stdout);
		}
	}
	return 0;
}
