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 <cstdio>
#include <deque>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e6 + 7;
const int mod = 998244353;
int n1, n2, m, q;
int h;
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int sub(int a, int b) { return a >= b ? a - b : a - b + mod; }
int mul(int a, int b) { return a * 1ll * b % mod; }
int qpow(int x)
{
    int ans = 1, two = 2;
    while (x)
    {
        if (x & 1) ans = mul(ans, two);
        two = mul(two, two);
        x >>= 1;
    }
    return ans;
}
deque<pii> dq[maxn];
int qcnt;
void h_push_back(int d, int e, int& c)
{
    int tmp = dq[d].back().second ^ 1;
    if (tmp) c = add(c, qpow(e));
    dq[d].push_back(make_pair(e, tmp));
}
void h_push_front(int d, int e, int& c)
{
    int tmp = dq[d].front().second ^ 1;
    if (tmp) c = add(c, qpow(e));
    dq[d].push_front(make_pair(e, tmp));
}
void h_reverse(int d)
{
    stack<pii> s;
    while (!dq[d].empty())
    {
        s.push(dq[d].front());
        dq[d].pop_front();
    }
    while (!s.empty())
    {
        dq[d].push_back(s.top());
        s.pop();
    }
}
struct path
{
    int s, t, d, c;
    path() {}
    path(int s, int t, int d) : s(s), t(t), d(d) { c = 0; }
    int front() { return dq[d].front().first; }
    int back() { return dq[d].back().first; }
    void push_back(int e) { h_push_back(d, e, c); }
    void push_front(int e) { h_push_front(d, e, c); }
    void pop_front() { dq[d].pop_front(); }
    void pop_back() { dq[d].pop_back(); }
    path add_back(path o)
    {
        path ans = *this;
        while (o.size())
        {
            ans.push_back(o.front());
            o.pop_front();
        }
        ans.t = o.t;
        return ans;
    }
    path add_front(path o)
    {
        path ans = *this;
        while (o.size())
        {
            ans.push_front(o.back());
            o.pop_back();
        }
        ans.s = o.s;
        return ans;
    }
    void reverse() { h_reverse(d); swap(s, t); }
    int size() { return dq[d].size(); }
    bool empty() { return dq[d].empty(); }
}p[maxn];
int pcnt, ecnt;
set<int> pset;
vector<int> vtx[400007];
path concatenate_path(int a, int b, int v)
{
    if (p[a].size() < p[b].size()) swap(a, b);
    if (p[a].s == v)
    {
        if (p[b].s == v) p[b].reverse();
        return p[a].add_front(p[b]);
    }
    else
    {
        if (p[b].t == v) p[b].reverse();
        return p[a].add_back(p[b]);
    }
}
void merge_path(int a, int b, int v)
{
    if (a == b) return;
    p[pcnt++] = concatenate_path(a, b, v);
    h = sub(h, p[a].c);
    h = sub(h, p[b].c);
    h = add(h, p[pcnt - 1].c);
    pset.insert(pcnt - 1);
    pset.erase(a);
    pset.erase(b);
    for (int& i : vtx[p[a].s]) if (i == a || i == b) i = pcnt - 1;
    for (int& i : vtx[p[a].t]) if (i == a || i == b) i = pcnt - 1;
    for (int& i : vtx[p[b].s]) if (i == a || i == b) i = pcnt - 1;
    for (int& i : vtx[p[b].t]) if (i == a || i == b) i = pcnt - 1;
}
void compress_vertex(int v)
{
    while (vtx[v].size() >= 2)
    {
        int a = vtx[v].back(); vtx[v].pop_back();
        int b = vtx[v].back(); vtx[v].pop_back();
        merge_path(a, b, v);
    }
}
void add_edge(int u, int v)
{
    p[pcnt++] = path(u, v, qcnt++);
    dq[qcnt - 1].push_back(make_pair(++ecnt, 0));
    vtx[u].push_back(pcnt - 1);
    vtx[v].push_back(pcnt - 1);
    pset.insert(pcnt - 1);
    compress_vertex(u);
    compress_vertex(v);
}
void print_graph()
{
    vector<int> ans;
    for (int index : pset)
    {
        for (pii tmp : dq[p[index].d])
        {
            if (tmp.second) ans.push_back(tmp.first);
        }
    }
    printf("%d", ans.size());
    for (int i : ans) printf(" %d", i);
    printf("\n");
}
int main()
{
    scanf("%d%d%d", &n1, &n2, &m);
    for (int i = 1; i <= m; ++i)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        v += 200000;
        add_edge(u, v);
    }
    scanf("%d", &q);
    while (q--)
    {
        int op;
        scanf("%d", &op);
        if (op == 1)
        {
            int u, v;
            scanf("%d%d", &u, &v);
            v += 200000;
            add_edge(u, v);
            printf("%d\n", h);
        }
        else
        {
            print_graph();
        }
        fflush(stdout);
    }
}