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 inf = 0x3f3f3f3f;
int n, h[200005], cnt, T, qy[200005], stky[200005 * 20];
int m, fa[200005], f[200005], siz[200005], stkx[200005 * 20];
int q, L[200005 << 1], R[200005 << 1], qx[200005], top;
struct node {
  int to, next;
} e[200005 << 1];
struct edge {
  int x, y, z;
  edge(int _x = 0, int _y = 0, int _z = 0) { x = _x, y = _y, z = _z; }
} E[200005 << 1];
unordered_map<int, int> mp[200005];
struct Xian {
  int c[35];
  void Add(int x) {
    for (int i = 30; ~i; --i)
      if (x >> i & 1) {
        if (!c[i]) return c[i] = x, void();
        x ^= c[i];
      }
  }
  int Ask(int x) {
    for (int i = 30; ~i; --i)
      if ((x ^ c[i]) < x) x ^= c[i];
    return x;
  }
} tmp;
inline int read() {
  int s = 0, f = 0;
  char ch = getchar();
  while (ch < 48 || ch > 57) f = (ch == '-'), ch = getchar();
  while (ch > 47 && ch < 58)
    s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return f ? -s : s;
}
vector<edge> t[200005 << 2];
void Insert(int p, int l, int r, int ql, int qr, edge x) {
  if (ql <= l && r <= qr) return t[p].push_back(x);
  int mid = l + r >> 1;
  if (ql <= mid) Insert(p << 1, l, mid, ql, qr, x);
  if (qr > mid) Insert(p << 1 | 1, mid + 1, r, ql, qr, x);
}
int Getfa(int x) { return x == fa[x] ? x : Getfa(fa[x]); }
int Getdis(int x) { return x == fa[x] ? 0 : f[x] ^ Getdis(fa[x]); }
void Solve(int p, int l, int r, Xian tmp) {
  int now = top, mid = l + r >> 1;
  for (edge tp : t[p]) {
    int x = tp.x, y = tp.y, z = tp.z ^ Getdis(x) ^ Getdis(y), fx = Getfa(x),
        fy = Getfa(y);
    if (fx == fy)
      tmp.Add(z);
    else {
      if (siz[fx] > siz[fy]) swap(fx, fy), swap(x, y);
      stkx[++top] = fx, stkx[++top] = fy, siz[fy] += siz[fx], fa[fx] = fy,
      f[fx] = z;
    }
  }
  if (l == r)
    cout << tmp.Ask(Getdis(qx[l]) ^ Getdis(qy[l])) << "\n";
  else
    Solve(p << 1, l, mid, tmp), Solve(p << 1 | 1, mid + 1, r, tmp);
  while (top > now)
    fa[stkx[top]] = stkx[top], siz[stky[top]] -= siz[stkx[top]],
    f[stkx[top--]] = 0;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; ++i) fa[i] = i, siz[i] = 1;
  for (int i = T = 1, x, y, z; i <= m; ++i) {
    x = read(), y = read(), z = read();
    mp[x][y] = mp[y][x] = i, L[i] = 1, R[i] = -1, E[i] = edge(x, y, z);
  }
  for (int q = read(), opt, x, y, z; q; --q) {
    opt = read(), x = read(), y = read();
    if (opt == 1) {
      z = read(), mp[x][y] = mp[y][x] = ++m;
      L[m] = T, R[m] = -1, E[m] = edge(x, y, z);
    } else if (opt == 2)
      R[mp[x][y]] = T - 1;
    else
      qx[T] = x, qy[T] = y, ++T;
  }
  for (int i = 1; i <= m; ++i)
    if (R[i] == -1) R[i] = T - 1;
  for (int i = 1; i <= m; ++i)
    if (L[i] <= R[i]) Insert(1, 1, T - 1, L[i], R[i], E[i]);
  Solve(1, 1, T - 1, tmp);
  return 0;
}