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>

#define fi first
#define se second
#define DB double
#define U unsigned
#define P std::pair
#define LL long long
#define LD long double
#define pb emplace_back
#define MP std::make_pair
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 4e5 + 5;
const int ha = 998244353;

inline void add(int &x,int y){
    x += y-ha;x += x>>31&ha;
}

int f[MAXN],col[MAXN],od[MAXN];
int sm[MAXN][2],to[MAXN][2];
int n,m,ans,cnt,val=1;

inline int find(int x){
    if(x == f[x]) return x;
    int y = f[x],t = find(y);
    col[x] ^= col[y];
    return f[x] = t;
}

inline void link(int x,int y){
    (val <<= 1) %= ha;++cnt;f[cnt] = cnt;
    if(od[x] < od[y]) std::swap(x,y);
    if(!od[x]){
        od[x] ^= 1;od[y] ^= 1;
        to[x][0] = y;to[y][0] = x;
        to[x][1] = to[y][1] = cnt;
        sm[cnt][0] = val;
        return;
    }
    if(!od[y]){
        od[x] ^= 1;od[y] ^= 1;
        int z = to[x][0],w = to[x][1],rt = find(w);
        to[x][0] = to[x][1] = 0;
        to[y][0] = z;to[z][0] = y;to[y][1] = cnt;
        col[cnt] = col[w]^1;
        f[cnt] = rt;
        add(sm[rt][col[cnt]],val);
        if(col[cnt]) add(ans,val);
        return;
    }
    od[x] ^= 1;od[y] ^= 1;
    int a = to[x][0],w1 = to[x][1],b = to[y][0],w2 = to[y][1];
    int r1 = find(w1),r2 = find(w2);
    to[a][0] = b;to[b][0] = a;
    if(a == y){
        f[cnt] = r1;
        col[cnt] = col[w1]^1;
        add(sm[r1][col[cnt]],val);
        if(col[cnt]) add(ans,val);
        return;
    }
    col[cnt] = col[w1]^1;f[cnt] = r1;
    add(sm[r1][col[cnt]],val);
    if(col[cnt]) add(ans,val);

    f[r2] = r1;col[r2] = col[w1]^col[w2];
    add(sm[r1][0],sm[r2][col[r2]]);
    add(sm[r1][1],sm[r2][!col[r2]]);
    if(col[r2]) add(ans,sm[r2][0]),add(ans,ha-sm[r2][1]);
}

int main(){
    int q;scanf("%d%d%d",&n,&m,&q);
    FOR(i,1,q){
        int u,v;scanf("%d%d",&u,&v);
        link(u,n+v);
    }
    scanf("%d",&q);
    while(q--){
        int o;scanf("%d",&o);
        if(o == 1){
            int x,y;scanf("%d%d",&x,&y);
            link(x,n+y);
            printf("%d\n",ans);
        }
        else{
            std::vector<int> ans;
            FOR(i,1,cnt){
                find(i);
                if(col[i]) ans.pb(i);
            }
            printf("%d ",SZ(ans));
            for(auto x:ans) printf("%d ",x);puts("");
        }
        std::fflush(stdout);
    }
    return 0;
}