Problem: You are given an undirected connected graph with weighted edges. The length of some path between two vertices is the bitwise xor of weights of all edges belonging to this path (if some edge is traversed more than once, then it is included in bitwise xor the same number of times). 

There are three types of queries you have to process:

  * 1 x y d — add an edge connecting vertex x to vertex y with weight d. It is guaranteed that there is no edge connecting x to y before this query; 
  * 2 x y — remove an edge connecting vertex x to vertex y. It is guaranteed that there was such edge in the graph, and the graph stays connected after this query; 
  * 3 x y — calculate the length of the shortest path (possibly non-simple) from vertex x to vertex y. 



Print the answers for all queries of type 3.

Input

The first line contains two numbers n and m (1 ≤ n, m ≤ 200000) — the number of vertices and the number of edges in the graph, respectively.

Then m lines follow denoting the edges of the graph. Each line contains three integers x, y and d (1 ≤ x < y ≤ n, 0 ≤ d ≤ 230 - 1). Each pair (x, y) is listed at most once. The initial graph is connected.

Then one line follows, containing an integer q (1 ≤ q ≤ 200000) — the number of queries you have to process.

Then q lines follow, denoting queries in the following form:

  * 1 x y d (1 ≤ x < y ≤ n, 0 ≤ d ≤ 230 - 1) — add an edge connecting vertex x to vertex y with weight d. It is guaranteed that there is no edge connecting x to y before this query; 
  * 2 x y (1 ≤ x < y ≤ n) — remove an edge connecting vertex x to vertex y. It is guaranteed that there was such edge in the graph, and the graph stays connected after this query; 
  * 3 x y (1 ≤ x < y ≤ n) — calculate the length of the shortest path (possibly non-simple) from vertex x to vertex y. 



It is guaranteed that at least one query has type 3.

Output

Print the answers for all queries of type 3 in the order they appear in input.

Example

Input

5 5
1 2 3
2 3 4
3 4 5
4 5 6
1 5 1
5
3 1 5
1 1 3 1
3 1 5
2 1 5
3 1 5


Output

1
1
2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
int n, m, t, c, U[N], Q, V[N], f[N], s[N], a[20][30], p[N];
map<pair<int, int>, int> mp;
struct O {
  int x, y, z;
} e[N], q[N];
vector<O> g[N << 1], b[N << 1];
void ins(int x, int y, int z) {
  e[++c] = (O){x, y, z};
  U[c] = t + 1;
  V[c] = -1;
  mp[make_pair(x, y)] = c;
}
int F(int x) {
  while (x != f[x]) x = f[x];
  return x;
}
int G(int x) {
  int v = 0;
  while (x != f[x]) v ^= p[x], x = f[x];
  return v;
}
void upd(int k, int l, int r, int L, int R, int i) {
  if (L <= l && r <= R) {
    g[k].push_back(e[i]);
    return;
  }
  if (((l + r) >> 1) >= L) upd(k << 1, l, ((l + r) >> 1), L, R, i);
  if (((l + r) >> 1) < R) upd(k << 1 | 1, ((l + r) >> 1) + 1, r, L, R, i);
}
void qry(int k, int l, int r, int d) {
  for (int i = 0; i < 30; i++) a[d][i] = a[d - 1][i];
  int z = g[k].size(), w;
  for (int x, y, u, v, i = 0; i < z; i++) {
    u = g[k][i].x;
    v = g[k][i].y;
    w = g[k][i].z;
    x = F(u);
    y = F(v);
    w ^= G(u) ^ G(v);
    if (x == y) {
      for (int i = 29; ~i; i--)
        if (w & (1 << i)) {
          if (!a[d][i]) {
            a[d][i] = w;
            break;
          }
          w ^= a[d][i];
        }
      continue;
    }
    if (s[x] > s[y]) swap(x, y), swap(u, v);
    b[k].push_back((O){x, y, s[y]});
    p[x] = w;
    f[x] = y;
    s[y] += s[x];
  }
  if (l == r) {
    w = G(q[l].x) ^ G(q[l].y);
    for (int i = 29; ~i; i--) w = min(w, w ^ a[d][i]);
    printf("%d\n", w);
  } else
    qry(k << 1, l, ((l + r) >> 1), d + 1),
        qry(k << 1 | 1, ((l + r) >> 1) + 1, r, d + 1);
  z = b[k].size();
  for (int u, i = z - 1; ~i; i--)
    s[b[k][i].y] = b[k][i].z, p[u = b[k][i].x] = 0, f[u] = u;
}
int main() {
  cin >> n >> m;
  for (int x, y, z, i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    if (x > y) swap(x, y);
    ins(x, y, z);
  }
  cin >> Q;
  for (int op, x, y, z; Q--;) {
    scanf("%d%d%d", &op, &x, &y);
    if (x > y) swap(x, y);
    if (op < 2)
      scanf("%d", &z), V[mp[make_pair(x, y)]] = t, ins(x, y, z);
    else if (op < 3)
      V[mp[make_pair(x, y)]] = t, mp[make_pair(x, y)] = 0;
    else
      q[++t] = (O){x, y, 0};
  }
  for (int i = 1; i <= c; i++) {
    if (!~V[i]) V[i] = t;
    if (U[i] <= V[i]) upd(1, 1, t, U[i], V[i], i);
  }
  for (int i = 1; i <= n; i++) f[i] = i, s[i] = 1;
  qry(1, 1, t, 1);
  return 0;
}