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 <cctype>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <list>
using namespace std;

#define LOG(f...) fprintf(stderr, f)

using ll = long long;

template<class T> void read(T &x) {
  char ch; x = 0;
  int f = 1;
  while (isspace(ch = getchar()));
  if (ch == '-') ch = getchar(), f = -1;
  do x = x * 10 + (ch - '0'); while(isdigit(ch = getchar()));
  x *= f;
}
template<class T, class ...A> void read(T &x, A&... args) { read(x); read(args...); }

#define assert_f(expr, fmt...) (!!(expr) || (LOG("Assertion Failed!\n"), LOG(fmt), LOG("\n"), abort(), true))

const int M = 998244353;
const int N = 400005;

int add(int x, int y) { return x + y >= M ? x + y - M : x + y; }
void inc(int &x, int y) { x += y; if (x >= M) x -= M; }
void dec(int &x, int y) { x -= y; if (x < 0) x += M; }

list<int> path[N];
int match[N];
int pc = 0;
int id[N];
int ec = 0;
int res[N], rc = 0, Hash = 0;
bool col[N];
int pow2[N];
int n1, n2, m;

pair<int, int> EDGE[N];
int EC = 0, deg[N];

void link(int u, int v) {
  ++ec;
  if (!id[u] && !id[v]) {
    path[++pc] = {ec};
    id[u] = pc; id[v] = -pc;
    match[u] = v; match[v] = u;
    return;
  }
  if (id[v] && !id[u]) swap(u, v);
  if (id[u] && !id[v]) {
    id[v] = id[u]; id[u] = 0;
    match[match[u]] = v;
    match[v] = match[u];
    match[u] = 0;
    if (id[v] > 0) {
      if (!col[path[id[v]].front()]) {
        col[ec] = true;
        inc(Hash, pow2[ec]);
      }
      path[id[v]].emplace_front(ec);
    }
    else {
      if (!col[path[-id[v]].back()]) {
        col[ec] = true;
        inc(Hash, pow2[ec]);
      }
      path[-id[v]].emplace_back(ec);
    }
  }
  else { // id[u] && id[v]
    if (id[u] == -id[v]) {
      if (!col[path[abs(id[u])].front()])
        col[ec] = true, inc(Hash, pow2[ec]);
      path[abs(id[u])].clear();
      id[u] = id[v] = 0;
      match[u] = match[v] = 0;
      return;
    }
    if (path[abs(id[u])].size() > path[abs(id[v])].size())
      swap(u, v);
    if ((id[u] > 0) == (id[v] > 0)) {
      path[abs(id[u])].reverse();
      id[u] = -id[u];
      id[match[u]] = -id[match[u]];
    }
    bool col_u = id[u] > 0 ? col[path[id[u]].front()] : col[path[-id[u]].back()];
    bool col_v = id[v] > 0 ? col[path[id[v]].front()] : col[path[-id[v]].back()];
    if (col_u != col_v) {
      for (int e : path[abs(id[u])]) {
        if (col[e]) dec(Hash, pow2[e]), col[e] = false;
        else inc(Hash, pow2[e]), col[e] = true;
      }
    }
    if (id[v] > 0) {
      path[id[v]].push_front(ec);
      path[id[v]].splice(path[id[v]].begin(), path[-id[u]]);
    }
    else {
      path[-id[v]].push_back(ec);
      path[-id[v]].splice(path[-id[v]].end(), path[id[u]]);
    }
    int del_id = abs(id[u]);
    int cnt = 0;
    for (int i = 1; i <= n1 + n2; ++i)
      cnt += abs(id[i]) == del_id;
    id[match[u]] = id[v];
    match[match[v]] = match[u];
    match[match[u]] = match[v];
    match[u] = match[v] = 0;
    if (!col_v)
      col[ec] = true, inc(Hash, pow2[ec]);
    id[u] = id[v] = 0;
  }
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  pow2[0] = 1;
  for (int i = 1; i <= 400000; ++i)
    pow2[i] = pow2[i - 1] * 2 % M;

  read(n1, n2, m);
  while (m--) {
    int u, v;
    read(u, v);
    link(u, v + n1);
  }

  int Q;
  read(Q);
  while (Q--) {
    int opt, u, v;
    read(opt);
    if (opt == 1) {
      read(u, v);
      link(u, v + n1);
      printf("%d\n", Hash); fflush(stdout);
    }
    else {
      rc = 0;
      for (int i = 1; i <= ec; ++i)
        if (col[i]) res[rc++] = i;
      printf("%d\n", rc);
      for (int i = 0; i < rc; ++i) printf("%d ", res[i]);
      putchar('\n'); fflush(stdout);
    }
  }
  return 0;
}