#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <functional>
#include <ctime>
#include <sstream>
#include <array>
#include <iomanip>
#include <list>
#include <random>

using namespace std;
typedef long long Long;
typedef long double Double;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Long> VL;
typedef vector<VL> VVL;
typedef pair<int,int> PII;
typedef pair<Long,Long> PLL;

int read(int &x) { return scanf("%d", &x); }
int read(int &x, int &y) { return scanf("%d%d", &x, &y); }
int read(int &x, int &y, int &z) { return scanf("%d%d%d", &x, &y, &z); }
int read(Long &x) { return scanf("%lld", &x); }
int read(Long &x, Long &y) { return scanf("%lld%lld", &x, &y); }
int read(double &x) { return scanf("%lf", &x); }
char buff[2000010];
int read(string &s) { int r = scanf("%s", buff); s = buff; return r; }

#define dlog2(n) ((n) == -1 ? 0 : (31-__builtin_clz(n)))


struct Node {
    Node *p, *n;
    int val;

    Node(int val) : val(val), p(NULL), n(NULL) {}
};

#define MOD 998244353
int HASH[1000010];

struct LinkedList {
    int odd = 0, even = 0;
    list<int> ll;
    void pushBack(int val) {
        ll.push_back(val);
        if (ll.size() % 2 == 0) {
            even += HASH[val];
            if (even >= MOD) even -= MOD;
        } else {
            odd += HASH[val];
            if (odd >= MOD) odd -= MOD;
        }
    }
    void pushFront(int val) {
        ll.push_front(val);
        swap(even, odd);
        odd += HASH[val];
        if (odd >= MOD) odd -= MOD;
    }
};
struct ListView {
    LinkedList list;
    int st, en;
    ListView(int st, int en) :st(st), en(en) {}
    VI iterate(int ost) {
        return ost == st ? VI(list.ll.begin(), list.ll.end()) : VI(list.ll.rbegin(), list.ll.rend());
    }
    int getOther(int ost) {
        return ost == st ? en : st;
    }
};

struct Ans {
    int v = 0;
    void rem(int a) {
        v -= a;
        if (v < 0) v += MOD;
    }
    void add(int a) {
        v += a;
        if (v >= MOD) v -= MOD;
    }
};

int main() {

    int TC = 1;
//    read(TC);
    while (TC-->0) {
        int n1, n2, m;
        read(n1, n2, m);
        vector<ListView*> V(n1 + n2, NULL);
        int edgeId = 0;
        vector<ListView*> cycles;
        HASH[0] = 1;
        Ans resp;
        auto merge = [](ListView* &a, ListView *&b) {
            if (a->list.ll.size() < b->list.ll.size()) swap(a, b);
            if (b->st == a->en || b->en == a->en) {
                for (int e : b->iterate(a->en)) a->list.pushBack(e);
                a->en = b->getOther(a->en);
            } else {
                for (int e : b->iterate(a->st)) a->list.pushFront(e);
                a->st = b->getOther(a->st);
            }
        };
        auto addEdge = [&](int a, int b) {
            edgeId++;
            HASH[edgeId] = HASH[edgeId-1] * 2 % MOD;
            if (V[a] == NULL && V[b] == NULL) {
                V[a] = V[b] = new ListView(a, b);
                V[a]->list.pushBack(edgeId);
                resp.add(V[a]->list.odd);
            } else if (V[a] == NULL) {
                resp.rem(V[b]->list.odd);
                if (V[b]->st == b) {
                    V[b]->list.pushFront(edgeId);
                    V[b]->st = a;
                } else {
                    V[b]->list.pushBack(edgeId);
                    V[b]->en = a;
                }
                swap(V[a], V[b]);
                resp.add(V[a]->list.odd);
            } else if (V[b] == NULL) {
                resp.rem(V[a]->list.odd);
                if (V[a]->st == a) {
                    V[a]->list.pushFront(edgeId);
                    V[a]->st = b;
                } else {
                    V[a]->list.pushBack(edgeId);
                    V[a]->en = b;
                }
                swap(V[a], V[b]);
                resp.add(V[b]->list.odd);
            } else {
                auto big = V[a];
                auto small = V[b];
                resp.rem(big->list.odd);
                V[big->st] = V[big->en] = V[small->st] = V[small->en] = NULL;
                if (big->en == a) big->list.pushBack(edgeId), big->en = b;
                else             big->list.pushFront(edgeId), big->st = b;
                if (big == small) {
                    cycles.push_back(big);
                    resp.add(big->list.odd);
                } else {
                    resp.rem(small->list.odd);
                    merge(big, small);
                    delete small;
                    V[big->st] = big;
                    V[big->en] = big;
                    resp.add(big->list.odd);
                }
            }
        };
        for (int i = 0; i < m; ++i) {
            int u,v;
            read(u, v);
            u--;v--;
            addEdge(u, v+n1);
        }
        int Q;
        read(Q);
        for (int i = 0; i < Q; ++i) {
            int c;
            read(c);
            if (c == 1) {
                int u, v;
                read(u, v);
                u--;v--;
                addEdge(u, v+n1);
                cout << resp.v << endl;
            } else {
                VI E;
                for (auto c : cycles) {
                    auto T = c->iterate(c->st);
                    for (int i = 0; i < T.size(); i += 2) {
                        E.push_back(T[i]);
                    }
                }
                for (int i = 0; i < V.size(); ++i) {
                    if (V[i] != NULL && V[i]->st == i) {
                        auto T = V[i]->iterate(i);
                        for (int j = 0; j < T.size(); j += 2) {
                            E.push_back(T[j]);
                        }
                    }
                }
                sort(E.begin(), E.end());
                cout << E.size() << " ";
                for (int e : E) {
                    cout << e << " ";
                }
                cout << endl;
            }
        }
    }


}
/*

6 6
1
0
0
1
1


 */