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;
map<pair<int, int>, int> S;
struct Q {
  int x, y;
} g[400010 << 2];
struct edge {
  int u, v, c, s, t;
} G[400010 << 2];
int n, m, cnt, qc, qn, clk, f[400010], v[400010], s[400010 << 2], t, r[400010];
struct Lbase {
  int p[31];
  Lbase() { memset(p, 0, sizeof p); }
  inline void add(int x) {
    for (int i = 30; ~i; --i)
      if (x & (1 << i))
        if (!p[i]) {
          p[i] = x;
          return;
        } else
          x ^= p[i];
  }
  inline int query(int x) {
    for (int i = 30; ~i; --i)
      if (x > (x ^ p[i])) x ^= p[i];
    return x;
  }
} Z;
inline int gf(int x, int& y, int r = 0) {
  for (y = x; y != f[y]; y = f[y]) r ^= v[y];
  return r;
}
inline void merge(int x, int y, int d) {
  if (r[x] > r[y]) swap(x, y);
  if (r[x] == r[y]) {
    ++r[y];
    s[++t] = -y;
  }
  f[x] = y;
  s[++t] = x;
  v[x] = d;
}
inline void back(int dt) {
  for (; t > dt; --t) s[t] < 0 ? --r[-s[t]] : f[s[t]] = s[t], v[s[t]] = 0;
}
inline void cdq(int l, int r, int n, Lbase B) {
  int dt = t, m = l + r >> 1, i, j;
  for (int i = 1; i <= n; ++i)
    if (G[i].s <= l && r <= G[i].t) {
      int x, y, d = gf(G[i].u, x) ^ gf(G[i].v, y);
      if (x != y)
        merge(x, y, G[i].c ^ d);
      else
        B.add(d ^ G[i].c);
      swap(G[i--], G[n--]);
    }
  if (l == r) {
    printf("%d\n", B.query(gf(g[l].x, j) ^ gf(g[l].y, j)));
    back(dt);
    return;
  }
  for (i = 1, j = n; i <= j; ++i)
    if (G[i].s > m) swap(G[i--], G[j--]);
  cdq(l, m, j, B);
  for (i = 1, j = n; i <= j; ++i)
    if (G[i].t <= m) swap(G[i--], G[j--]);
  cdq(m + 1, r, j, B);
  back(dt);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) f[i] = i;
  for (int x, y, c, i = 1; i <= m; ++i) {
    scanf("%d%d%d", &x, &y, &c);
    G[++cnt] = (edge){x, y, c, 1, -1};
    S[make_pair(x, y)] = cnt;
  }
  scanf("%d", &m);
  for (int o, x, y, c, i = 1; i <= m; ++i) {
    scanf("%d%d%d", &o, &x, &y);
    if (o == 1) {
      scanf("%d", &c);
      G[++cnt] = (edge){x, y, c, clk + 1, -1};
      S[make_pair(x, y)] = cnt;
    } else if (o == 2) {
      G[S[make_pair(x, y)]].t = clk;
      S.erase(make_pair(x, y));
    } else {
      g[++clk] = (Q){x, y};
    }
  }
  for (int i = 1; i <= cnt; ++i)
    if (!~G[i].t) G[i].t = clk;
  cdq(1, clk, cnt, Z);
}