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