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:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 998244353//1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef  long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef ll ValType;
template<typename  T> void maxtt(T& t1, T t2) {
    t1=max(t1,t2);
}
template<typename  T> void mintt(T& t1, T t2) {
    t1=min(t1,t2);
}
#define MAX (400135)

bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
const ll MOD2 = (ll)MOD * (ll)MOD;
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD){
    x+=y; if (x>=mod) x-=mod;
    if(x<0) x+=mod;
    assert(x>=0 && x<mod);
}
void et(int x=-1) {
    printf("%d\n", x); exit(0);
}
ll fastPow(ll x, ll y, int mod=MOD) {
    ll ans = 1;
    while(y>0) {
        if(y&1) ans = (x * ans)%mod;
        x = x*x%mod;
        y>>=1;
    }
    return ans;
}
ll gcd1(ll x, ll y) {
    return y?gcd1(y,x%y):x;
}

//#include <atcoder/all>
//using mint = atcoder::modint1000000007;
int f[MAX], rev[MAX], res, sum[MAX][2];
int ff(int x) {
    if( x==f[x]) return x;
    if(f[f[x]]==f[x]) return f[x];
    int X=ff(f[x]);
    rev[x] ^= rev[f[x]];
    f[x]=X;
    return X;
}
bool reversed(int x) {
    if (x==f[x]) return rev[x];
    int X=ff(x);
    return rev[x]^rev[X];
}
void mg(int x, int y) {
    x=ff(x); y=ff(y);
    if(x==y) return;
    addmod(res, MOD-sum[x][rev[x]]);
    addmod(res, MOD-sum[y][rev[y]]);
    rev[x]^=rev[y];
    f[x]=y;
    addmod(sum[y][0], sum[x][rev[x]]);
    addmod(sum[y][1], sum[x][rev[x]^1]);
    addmod(res, sum[y][rev[y]]);
}
void REV(int x) {
    x=ff(x);
    addmod(res, MOD-sum[x][rev[x]]);
    rev[x]^=1;
    addmod(res, sum[x][rev[x]]);
}
int bt[MAX], to[MAX];
void lik(int x, int y, int id) {
    sum[id][1]=bt[id]=bt[id-1]*2%MOD;
    f[id]=id;
    if(to[x]==0 && to[y]==0) {
        REV(id); to[x]=to[y]=id; return;
    }
    if (to[x]==0) swap(x,y);
    if(to[y]==0) {
        if(!reversed(to[x])) REV(id);
        mg(to[x], id);
        to[y]=id; to[x]=0; return;
    }
    if(reversed(to[x]) ^ reversed(to[y])) REV(to[x]);
    if (!reversed(to[x])) REV(id);
    mg(to[x], id); mg(to[y], id);
    to[x]=to[y]=0;
}
void fmain(int tid) {
    int n1,n2;
    scanf("%d%d%d", &n1,&n2, &m); bt[0]=1;
    REQ(i,m) {
        int v,u;
        scanf("%d%d", &u,&v);
        lik(u, v+n1, i);
    }
    int q; scanf("%d", &q);
    REQ(i,q) {
        int ty,u,v; scanf("%d", &ty);
        if(ty==1) {
            scanf("%d%d", &u,&v); lik(u,v+n1,++m);
            printf("%d\n", res);
        } else {
            vector<int> ans;
            REQ(j,m) if(reversed(j)) ans.push_back(j);
            printf("%d ", (int)ans.size());
            for(int z: ans) printf("%d ", z); puts("");
        }
        fflush(stdout);
    }
}
int main() {
//    freopen("in21.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    int t=1;
//    init();
//    scanf("%d", &t);
    REQ(i,t) {
        fmain(i);
    }
    return 0;
}