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>
using namespace std;

const int MAX_N = 400000, MOD = 998244353;

struct mint {
    int x;

    mint() {}

    template <class T> mint(T value) : x(value % MOD) { if (x < 0) x += MOD; }

    mint & operator+=(const mint &oth) { x += oth.x; if (x >= MOD) x -= MOD; return *this; }

    mint & operator-=(const mint &oth) { x -= oth.x; if (x < 0) x += MOD; return *this; }

    mint & operator*=(const mint &oth) { x = (long long) x * oth.x % MOD; return *this; }

    friend mint operator+(mint l, const mint &r) { return l += r; }

    friend mint operator-(mint l, const mint &r) { return l -= r; }

    friend mint operator*(mint l, const mint &r) { return l *= r; }

    mint & operator--() { if (--x == -1) x = MOD - 1; return *this; }

    mint & operator++() { if (++x == MOD) x = 0; return *this; }

    mint operator--(int) { mint temp = *this; --*this; return temp; }

    mint operator++(int) { mint temp = *this; ++*this; return temp; }

    mint operator-() const { return 0 - *this; }

    mint operator+() const { return *this; }

    friend bool operator==(const mint &l, const mint &r) { return l.x == r.x; }

    friend bool operator!=(const mint &l, const mint &r) { return l.x != r.x; }

    friend ostream & operator<<(ostream &out, const mint &a) { return out << a.x; }

    mint pow(long long e = MOD - 2) const {
        mint ans = 1, b = *this;
        while (e > 0) {
            if (e % 2 == 1) {
                ans *= b;
            }
            b *= b;
            e /= 2;
        }
        return ans;
    }
};

int sub[MAX_N], par[MAX_N], edge[MAX_N], k;
mint all[MAX_N], red[MAX_N], sum;
bool offset[MAX_N];

pair<int, bool> find(int u) {
    if (par[u] == u) {
        return {u, false};
    } else {
        auto [p, x] = find(par[u]);
        offset[u] ^= x;
        par[u] = p;
        return {par[u], offset[u]};
    }
}

void unite(int u, int v) {
    auto [a, x] = find(u);
    auto [b, y] = find(v);

    if (a != b) {
        if (sub[a] > sub[b]) {
            swap(a, b), swap(x, y);
        }

        sub[b] += sub[a];
        par[a] = b;

        offset[a] = x ^ y ^ true;
        all[b] += all[a];
        red[b] += red[a];

        if (offset[a]) {
            sum += all[a] - 2 * red[a];
            red[b] += all[a] - 2 * red[a];
        }
    }
}

void update(int u, int v) {
    all[k] = mint(2).pow(k + 1);
    sub[k] = 1, par[k] = k;

    for (auto i : {u, v}) {
        if (edge[i] == -1) {
            edge[i] = k;
        } else {
            unite(k, edge[i]);
            edge[i] = -1;
        }
    }

    ++k;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n1, n2, m;
    cin >> n1 >> n2 >> m;

    fill(edge, edge + n1 + n2, -1);

    while (m--) {
        int u, v;
        cin >> u >> v;
        update(u - 1, n1 + v - 1);
    }

    int q;
    cin >> q;

    while (q--) {
        int t;
        cin >> t;

        if (t == 1) {
            int u, v;
            cin >> u >> v;
            update(u - 1, n1 + v - 1);
            cout << sum << endl;
        } else {
            vector<int> ans;
            for (int i = 0; i < k; ++i) {
                if (find(i).second) {
                    ans.push_back(i + 1);
                }
            }

            cout << ans.size() << " ";
            for (auto i : ans) {
                cout << i << " ";
            }
            cout << endl;
        }
    }
}