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;
int n, m, Q, sl, fa[200010], sz[200010], ds[200010];
pair<int, int> qry[200010];
struct edge {
  int u, v, w;
};
struct seg {
  vector<edge> vt;
  int flg;
} tr[200010 << 2];
struct xxj {
  int a[32];
  inline void ins(int x) {
    for (int i = 30; ~i; --i)
      if ((x >> i) & 1) {
        if (!a[i]) return (void)(a[i] = x);
        x ^= a[i];
      }
    return;
  }
  inline int qry(int x) {
    for (int i = 30; ~i; --i)
      if ((x ^ a[i]) < x) x ^= a[i];
    return x;
  }
} s[32];
vector<int> vt[32];
map<pair<int, int>, int> ex, vl;
inline char gc() {
  static char buf[1 << 16], *S, *T;
  if (S == T) {
    T = (S = buf) + fread(buf, 1, 1 << 16, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
inline int rd() {
  sl = 0;
  char ch = gc();
  while (ch < '0' || '9' < ch) ch = gc();
  while ('0' <= ch && ch <= '9') sl = sl * 10 + ch - '0', ch = gc();
  return sl;
}
void upd(int x, int l, int r, int p) {
  tr[x].flg = 1;
  if (l == r) return;
  if (p <= ((l + r) >> 1))
    upd(x << 1, l, ((l + r) >> 1), p);
  else
    upd(x << 1 | 1, ((l + r) >> 1) + 1, r, p);
}
void ins(int x, int l, int r, int L, int R, edge E) {
  if (L <= l && r <= R) return tr[x].vt.push_back(E);
  if (L <= ((l + r) >> 1)) ins(x << 1, l, ((l + r) >> 1), L, R, E);
  if (R > ((l + r) >> 1)) ins(x << 1 | 1, ((l + r) >> 1) + 1, r, L, R, E);
}
inline int getfa(int x) {
  for (; fa[x] != x; x = fa[x])
    ;
  return x;
}
inline int getds(int x) {
  int res = 0;
  for (; fa[x] != x; res ^= ds[x], x = fa[x])
    ;
  return res;
}
void solve(int x, int l, int r, int d) {
  s[d] = s[d - 1];
  vt[d].clear();
  int w, fx, fy;
  for (auto i : tr[x].vt) {
    fx = getfa(i.u);
    fy = getfa(i.v);
    w = i.w ^ getds(i.u) ^ getds(i.v);
    if (fx == fy)
      s[d].ins(w);
    else {
      if (sz[fx] < sz[fy])
        fa[fx] = fy, ds[fx] = w, sz[fy] += sz[fx], vt[d].push_back(fx);
      else
        fa[fy] = fx, ds[fy] = w, sz[fx] += sz[fy], vt[d].push_back(fy);
    }
  }
  if (l == r)
    printf("%d\n", s[d].qry(getds(qry[l].first) ^ getds(qry[l].second)));
  else {
    if (tr[x << 1].flg) solve(x << 1, l, ((l + r) >> 1), d + 1);
    if (tr[x << 1 | 1].flg) solve(x << 1 | 1, ((l + r) >> 1) + 1, r, d + 1);
  }
  for (auto i : vt[d]) {
    sz[fa[i]] -= sz[i];
    fa[i] = i;
    ds[i] = 0;
  }
}
int main() {
  n = rd();
  m = rd();
  int x, y, z;
  for (int i = 1; i <= m; ++i) {
    x = rd();
    y = rd();
    z = rd();
    ex[make_pair(x, y)] = 1;
    vl[make_pair(x, y)] = z;
  }
  Q = rd();
  for (int ty, i = 1; i <= Q; ++i) {
    ty = rd();
    if (ty == 1)
      x = rd(), y = rd(), z = rd(), ex[make_pair(x, y)] = i,
      vl[make_pair(x, y)] = z;
    else if (ty == 2) {
      x = rd();
      y = rd();
      ins(1, 1, Q, ex[make_pair(x, y)], i, (edge){x, y, vl[make_pair(x, y)]});
      ex[make_pair(x, y)] = 0;
    } else {
      x = rd();
      y = rd();
      qry[i] = make_pair(x, y);
      upd(1, 1, Q, i);
    }
  }
  for (map<pair<int, int>, int>::iterator i = ex.begin(); i != ex.end(); ++i)
    if (i->second)
      x = i->first.first, y = i->first.second,
      ins(1, 1, Q, i->second, Q, (edge){x, y, vl[make_pair(x, y)]});
  for (int i = 1; i <= n; ++i) fa[i] = i, sz[i] = 1;
  solve(1, 1, Q, 1);
  return 0;
}