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>
//#include <ext/pb_ds/assoc_container.hpp>

#define range(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ar array

typedef long long ll;

using namespace std;
//using namespace __gnu_pbds;

const int INFi = 2e9 + 5;
const int maxN = 4e5 + 100;
const int md = 998244353;
const ll INF = 2e18;

inline int add(const int &a, const int &b) {
    return a + b >= md ? a + b - md : a + b;
}

inline int sub(const int &a, const int &b) {
    return a - b < 0 ? a - b + md : a - b;
}

inline int mul(const int &a, const int &b) {
    return (1ll * a * b) % md;
}

int color[maxN];
int to[maxN];

int hashes[maxN];
int H = 0;

struct path {
    deque<int> vd;
    deque<int> edges;
    int i;
    int start_col;
    int end_col;

    void add_edge(int v, int u, int k) {
        if (vd.empty()) {
            vd.push_back(u);
            vd.push_back(v);
            to[v] = to[u] = i;
            edges.push_back(k);
            H = add(H, hashes[k]);
            color[k] = 1;
            start_col = end_col = 1;
            return;
        }
        to[v] = -1;
        if (vd.back() == v) {
            vd.push_back(u);
            edges.push_back(k);
            end_col ^= 1;
            if (end_col) {
                H = add(H, hashes[k]);
                color[k] = 1;
            } else {
                color[k] = -1;
            }
        } else if (vd.front() == v) {
            vd.push_front(u);
            edges.push_front(k);
            start_col ^= 1;
            if (start_col) {
                H = add(H, hashes[k]);
                color[k] = 1;
            } else {
                color[k] = -1;
            }
        } else {
            assert(0);
        }
        if (vd.back() == vd.front()) {
            to[vd.back()] = to[vd.front()] = -1;
            return;
        }
        to[u] = i;
    }

    void merge(path &b, int v, int u, int k) {
        if (b.i == i) {
            add_edge(v, u, k);
            return;
        }
        for (int j = 0; j < b.edges.size(); ++j) {
            if ((j ^ b.start_col)&1 ) {
                H = sub(H, hashes[b.edges[j]]);
            }
        }
        if (b.vd.front() == u) {
            reverse(all(b.vd));
            reverse(all(b.edges));
        }
        to[b.vd.back()] = to[b.vd.front()] = -1;
        to[v] = -1;
        b.edges.push_back(k);
        if (vd.front() == v) {
            while (!b.vd.empty()) {
                k = b.edges.back();
                start_col ^= 1;
                if (start_col) {
                    H = add(H, hashes[k]);
                    color[k] = 1;
                } else {
                    color[k] = -1;
                }
                edges.push_front(k);
                vd.push_front(b.vd.back());
                b.vd.pop_back();
                b.edges.pop_back();
            }
        } else {
            assert(vd.back() == v);
            while (!b.vd.empty()) {
                k = b.edges.back();
                edges.push_back(k);
                end_col ^= 1;
                if (end_col) {
                    H = add(H, hashes[k]);
                    color[k] = 1;
                } else {
                    color[k] = -1;
                }
                vd.push_back(b.vd.back());
                b.vd.pop_back();
                b.edges.pop_back();
            }
        }
        assert(vd.back() != vd.front());
        to[vd.back()] = to[vd.front()] = i;
    }
};

path paths[maxN];
int R = 0;

int create() {
    paths[R].i = R;
    return R++;
}

int K = 1;

void init() {
    hashes[0] = 1;
    for (int i = 1; i < maxN; ++i) hashes[i] = mul(hashes[i - 1], 2);
}

void new_edge(int u, int v) {
    if (to[u] == -1 && to[v] == -1) {
        int nw = create();
        paths[nw].add_edge(v, u, K);
        K++;
        return;
    }
    if (to[u] != -1 && to[v] != -1) {
        if (paths[to[u]].vd.size() > paths[to[v]].vd.size()) {
            swap(u, v);
        }
        paths[to[v]].merge(paths[to[u]], v, u, K);
        K++;
        return;
    }
    if (to[v] == -1) swap(u, v);
    paths[to[v]].add_edge(v, u, K);
    K++;
}

void print() {
    vector<int> answer;
    for (int i = 1; i <= K; ++i) {
        if (color[i] == 1) answer.push_back(i);
    }
    cout << answer.size() << ' ';
    for (auto &u : answer) cout << u << ' ';
    cout << endl;
}

void solve() {
    init();
    int n1, n2, m;
    cin >> n1 >> n2 >> m;
    range(i, n1 + n2 + 5) to[i] = -1;
    range(_, m) {
        int u, v;
        cin >> u >> v;
        v += n1;
        new_edge(u, v);
    }
    int q;
    cin >> q;
    range(_, q) {
        int t;
        cin >> t;
        if (t == 1) {
            int v1, v2;
            cin >> v1 >> v2;
            v2 += n1;
            new_edge(v1, v2);
            cout << H << endl;
        } else {
            print();
        }
    }
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int tests = 1;
    //cin >> tests;
    range(_, tests) {
        solve();
    }
    return 0;
}