#include <bits/stdc++.h>
#define int long long

using namespace std;

const int mod = 998244353;

int n1, n2, m, q, paths;
int path[2][200000];
pair<bool, int> s[400000], e[400000];
deque<int> pathEdges[400000];
int h;
int hv[400000];
bool isRed[400000];

void updateEdgeColor(int id, bool red) {
    if (red == isRed[id]) return;
    if (red) h = (h + hv[id]) % mod;
    else h = (h - hv[id] + mod) % mod;
    isRed[id] = red;
}

void addEdge(int u, int v, int id) {
    if (path[0][u] == -1 && path[1][v] == -1) {
        path[0][u] = path[1][v] = paths;
        pathEdges[paths].push_back(id);
        s[paths] = {false, u};
        e[paths] = {true, v};
        paths++;
    } else if (path[0][u] != -1 && path[1][v] == -1) {
        int p = path[0][u];
        path[1][v] = p;
        path[0][u] = -1;
        if (s[p] == make_pair(false, u)) {
            isRed[id] = !isRed[pathEdges[p][0]];
            if (isRed[id]) h = (h + hv[id]) % mod;
            pathEdges[p].push_front(id);
            s[p] = {true, v};
        } else {
            isRed[id] = !isRed[pathEdges[p].back()];
            if (isRed[id]) h = (h + hv[id]) % mod;
            pathEdges[p].push_back(id);
            e[p] = {true, v};
        }
    } else if (path[0][u] == -1 && path[1][v] != -1) {
        int p = path[1][v];
        path[0][u] = p;
        path[1][v] = -1;
        if (s[p] == make_pair(true, v)) {
            isRed[id] = !isRed[pathEdges[p][0]];
            if (isRed[id]) h = (h + hv[id]) % mod;
            pathEdges[p].push_front(id);
            s[p] = {false, u};
        } else {
            isRed[id] = !isRed[pathEdges[p].back()];
            if (isRed[id]) h = (h + hv[id]) % mod;
            pathEdges[p].push_back(id);
            e[p] = {false, u};
        }
    } else if (path[0][u] == path[1][v]) {
        int p = path[0][u];
        path[0][u] = path[1][v] = -1;
        isRed[id] = !isRed[pathEdges[p][0]];
        if (isRed[id]) h = (h + hv[id]) % mod;
    } else {
        int p, q;
        bool front;
        if (pathEdges[path[0][u]].size() >= pathEdges[path[1][v]].size()) {
            p = path[0][u]; q = path[1][v];
            front = s[p] == make_pair(false, u);
            if (e[q] == make_pair(true, v)) {
                reverse(pathEdges[q].begin(), pathEdges[q].end());
                if (front) s[p] = s[q];
                else e[p] = s[q];
            } else {
                if (front) s[p] = e[q];
                else e[p] = e[q];
            }
        } else {
            p = path[1][v]; q = path[0][u];
            front = s[p] == make_pair(true, v);
            if (e[q] == make_pair(false, u)) {
                reverse(pathEdges[q].begin(), pathEdges[q].end());
                if (front) s[p] = s[q];
                else e[p] = s[q];
            } else {
                if (front) s[p] = e[q];
                else e[p] = e[q];
            }
        }

        path[0][u] = path[1][v] = -1;
        bool red;
        if (front) red = !isRed[pathEdges[p][0]];
        else red = !isRed[pathEdges[p].back()];

        updateEdgeColor(id, red);
        if (front) pathEdges[p].push_front(id);
        else pathEdges[p].push_back(id);
        red = !red;

        for (int e : pathEdges[q]) {
            updateEdgeColor(e, red);
            if (front) pathEdges[p].push_front(e);
            else pathEdges[p].push_back(e);
            red = !red;
        }

        if (front) path[s[p].first][s[p].second] = p;
        else path[e[p].first][e[p].second] = p;
    }
}

void printState() {
    vector<int> v;
    for (int i = 0; i < m; ++i) if (isRed[i]) v.push_back(i);
    cout << v.size();
    for (int a : v) cout << " " << a+1;
    cout << "\n" << flush;
}

int32_t main() {
    hv[0] = 2;
    for (int i = 1; i < 400000; ++i) hv[i] = (hv[i-1] * 2) % mod;

    cin >> n1 >> n2 >> m;
    for (int i = 0; i < n1; ++i) path[0][i] = -1;
    for (int i = 0; i < n2; ++i) path[1][i] = -1;
    for (int i = 0; i < m; ++i) {
        int x, y; cin >> x >> y; x--; y--;
        addEdge(x, y, i);
    }
    cin >> q;
    for (int z = 0; z < q; ++z) {
        int type; cin >> type;
        if (type == 2) printState();
        else {
            int x, y; cin >> x >> y; x--; y--;
            addEdge(x, y, m++);
            cout << h << "\n" << flush;
        }
    }
}
