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 <algorithm>
#include <vector>
#include <numeric>
#include <array>
#include <cassert>

#define DEBUG

using namespace std;
using ll = long long;

const int MOD = 998244353;

template<int N>
struct Dsu {
    array<int, N> p, r, d;
    array<array<int, N>, 2> h;
    ll hash;

    Dsu() : hash(0) {
        iota(p.begin(), p.end(), 0);
        fill(r.begin(), r.end(), 0);
        fill(d.begin(), d.end(), 0);
        for (int i = 0, z = 2; i < N; ++i) {
            h[0][i] = z;
            h[1][i] = 0;
            z += z;
            if (z >= MOD) z -= MOD;
        }
    }

    pair<int, int> getRoot(int v) {
        if (v == p[v]) return { v, 0 };
        auto [u, x] = getRoot(p[v]);
        return { p[v] = u, d[v] ^= x };
    }

    bool unite(int a, int b) {
        auto [v, x] = getRoot(a);
        auto [u, y] = getRoot(b);
        if (u != v) {
            hash += 2 * MOD - h[0][v] - h[0][u];
            if (r[v] < r[u]) swap(v, u);
            p[u] = v;
            d[u] = x ^ y ^ 1;
            if (d[u]) swap(h[0][u], h[1][u]);
            h[0][v] += h[0][u]; if (h[0][v] >= MOD) h[0][v] -= MOD;
            h[1][v] += h[1][u]; if (h[1][v] >= MOD) h[1][v] -= MOD;
            hash = (hash + h[0][v]) % MOD;
            if (r[v] == r[u]) ++r[v];
            return true;
        } else {
            return false;
        }
    }
};

const int N = 5e5+7;

int n1, n2, m, a[N], b[N], link[N], p2[N];
Dsu<N> dsu;

#ifdef DEBUG
int deg[N], cnt[N];
#endif

void processLink(int v, int i) {
    if (link[v] != -1) {
        dsu.unite(link[v], i);
        link[v] = -1;
    } else {
        link[v] = i;
    }
}

void addEdge(int i) {
    int u = a[i], v = b[i];
    dsu.hash += dsu.h[0][i];
    if (dsu.hash >= MOD) dsu.hash -= MOD;
    processLink(u, i);
    processLink(v, i);

#ifdef DEBUG
    deg[a[i]]++;
    deg[b[i]]++;
#endif
}

void printAnswer(int sz) {
#ifdef DEBUG
    fill(cnt, cnt+N, 0);
#endif
    vector<int> res;
    for (int i = 0; i < sz; ++i) {
        if (dsu.getRoot(i).second == 0) {
            res.push_back(i+1);
#ifdef DEBUG
            cnt[a[i]]++;
            cnt[b[i]]++;
#endif
        }
    }

    cout << res.size();
    for (int x : res) cout << ' ' << x;
    cout << endl;

#ifdef DEBUG
    for (int i = 1; i <= n1+n2; ++i) {
        assert(abs(2*cnt[i] - deg[i]) < 2);
    }
#endif
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n1 >> n2 >> m;
    fill(link, link+N, -1);

    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        b[i] += n1;
        addEdge(i);
    }

    int q; cin >> q;
    int sz = m;
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            cin >> a[sz] >> b[sz];
            b[sz] += n1;
            addEdge(sz++);
            cout << dsu.hash << endl;
        } else {
            printAnswer(sz);
        } 
    }
}