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 <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


 */