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 mod = 998244353;

// Based on code of tourist
class Mint {
  private:
    int value;
  public:
    constexpr Mint() : value() {}
    template <typename T>
    Mint(const T& x) {
        value = (-mod <= x && x < mod) ? x : x % mod;
        if (value < 0) value += mod;
    }
    template <typename U>
    explicit operator U() const { return static_cast<U>(value); }

    Mint& operator += (const Mint& a) { if ((value += a.value) >= mod) value -= mod; return *this; }
    Mint& operator -= (const Mint& a) { if ((value -= a.value) < 0) value += mod; return *this; }
    Mint& operator ++ () { return *this += 1; }
    Mint& operator -- () { return *this -= 1; }
    Mint operator ++ (int) { Mint result(*this); *this += 1; return result; }
    Mint operator -- (int) { Mint result(*this); *this -= 1; return result; }
    Mint operator - () const { return Mint(-value); }
    Mint& operator *= (const Mint& a) { value = (long long) value * a.value % mod; return *this; }
    Mint& operator /= (const Mint& a) { assert(a.value != 0); return *this *= inverse(a); }
    friend Mint pow(Mint a, int b) {
        Mint r = 1;
        for (; b; a *= a, b >>= 1) {
            if (b & 1) r *= a;
        }
        return r;
    }
    static Mint inverse(const Mint& a) {
        return pow(a, mod - 2);
    }
    friend bool operator == (const Mint& a, const Mint& b) { return a.value == b.value; }
    friend bool operator != (const Mint& a, const Mint& b) { return a.value != b.value; }
    friend bool operator < (const Mint& a, const Mint& b) { return a.value < b.value; }
    friend Mint operator + (const Mint& a, const Mint& b) { return Mint(a) += b; }
    friend Mint operator - (const Mint& a, const Mint& b) { return Mint(a) -= b; }
    friend Mint operator * (const Mint& a, const Mint& b) { return Mint(a) *= b; }
    friend Mint operator / (const Mint& a, const Mint& b) { return Mint(a) /= b; }
    friend ostream& operator << (ostream& stream, const Mint& a) {
        return stream << a.value;
    }
    friend istream& operator >> (istream& stream, Mint& a) {
        return stream >> a.value;
    }
    friend string to_string(const Mint& a) {
        return to_string(a.value);
    }
};

vector<int> color;
Mint _hash;
vector<deque<int>> paths;
vector<deque<int>> pathsV;
vector<vector<int>> adjacent_paths;

void check(int v) {
    if (adjacent_paths[v].size() <= 1) {
        return;
    }
    assert((int) adjacent_paths[v].size() == 2);
    int p1 = adjacent_paths[v][0];
    int p2 = adjacent_paths[v][1];
    assert(pathsV[p1].front() == v || pathsV[p1].back() == v);
    assert(pathsV[p2].front() == v || pathsV[p2].back() == v);
    adjacent_paths[v].clear();
    if (paths[p1].size() < paths[p2].size()) {
        swap(p1, p2);
    }
    int e1 = pathsV[p1].front() == v ? paths[p1].front() : paths[p1].back();
    int e2 = pathsV[p2].front() == v ? paths[p2].front() : paths[p2].back();
    if (color[e1] == color[e2]) {
        // recolor path p2
        for (int edge_id : paths[p2]) {
            color[edge_id] ^= 1;
            Mint change = pow(Mint(2), edge_id + 1);
            if (color[edge_id]) {
                _hash += change;
            } else {
                _hash -= change;
            }
        }
    }
    // merge p1-p2
    if (pathsV[p2].back() == v) {
        reverse(paths[p2].begin(), paths[p2].end());
        reverse(pathsV[p2].begin(), pathsV[p2].end());
    }
    bool put_front = pathsV[p1].front() == v;
    for (int b : paths[p2]) {
        if (put_front) {
            paths[p1].push_front(b);
        } else {
            paths[p1].push_back(b);
        }
    }
    bool first = true;
    for (int b : pathsV[p2]) {
        if (first) {
            first = false;
        } else {
            if (put_front) {
                pathsV[p1].push_front(b);
            } else {
                pathsV[p1].push_back(b);
            }
        }
    }
    int other = pathsV[p2].front() ^ pathsV[p2].back() ^ v;
    adjacent_paths[other].erase(find(adjacent_paths[other].begin(), adjacent_paths[other].end(), p2));
    adjacent_paths[other].push_back(p1);
    paths[p2].clear();
    pathsV[p2].clear();
    int f = pathsV[p1].front();
    int b = pathsV[p1].back();
    if (f == b) {
        assert((int) adjacent_paths[f].size() == 2 || adjacent_paths[f].empty());
        adjacent_paths[f].clear();
    }
}

void add(int a, int b) {
    int edge_id = color.size();
    color.push_back(0);
    int id = paths.size();
    deque<int> np;
    np.push_back(edge_id);
    paths.push_back(np);
    deque<int> npv;
    npv.push_back(a);
    npv.push_back(b);
    pathsV.push_back(npv);
    adjacent_paths[a].push_back(id);
    adjacent_paths[b].push_back(id);
    check(a);
    check(b);
}

void foo() {
    int n1, n2, m;
    cin >> n1 >> n2 >> m;
    adjacent_paths.assign(n1 + n2, vector<int>());
    _hash = 0;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        y += n1;
        x--, y--;
        add(x, y);
    }
    
    int q;
    cin >> q;
    while(q--) {
        int type;
        cin >> type;
        if (type == 1) {
            int x, y;
            cin >> x >> y;
            x--, y--;
            y += n1;
            add(x, y);
            cout << _hash << endl;
        } else {
            vector<int> red;
            for (int i = 0; i < (int) color.size(); i++) {
                if (color[i]) {
                    red.push_back(i);
                }
            }
            cout << red.size();
            for (int x : red) {
                cout << ' ' << x + 1;
            }
            cout << endl;
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    foo();
}