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 maxn = 2e5 + 5, Mx = 30;
struct BASIS {
  int a[Mx + 5];
  BASIS() { memset(a, 0, sizeof(a)); }
  void insert(int x) {
    for (int i = Mx; i >= 0; --i) {
      if (!(x >> i & 1)) continue;
      if (!a[i]) return void(a[i] = x);
      x ^= a[i];
    }
  }
  int query(int ans) {
    for (int i = Mx; i >= 0; --i)
      if ((ans ^ a[i]) < ans) ans ^= a[i];
    return ans;
  }
} preb;
struct edge {
  int u, v, l, r, w;
} e[maxn << 1];
map<pair<int, int>, int> eus;
int fa[maxn], n, m, lim, ecnt, qx[maxn], qy[maxn], fdis[maxn], dep[maxn];
vector<int> wife[maxn << 2];
template <typename T>
inline void read(T &x) {
  char c;
  int f = 1;
  while (!isdigit(c = getchar())) (c == '-') && (f = -1);
  x = c ^ 48;
  while (isdigit(c = getchar())) x = x * 10 + (c ^ 48);
  x *= f;
}
void modify(int u, int l, int r, int x, int y, int id) {
  if (x <= l && r <= y) return void(wife[u].push_back(id));
  int mid = (l + r) >> 1;
  if (x <= mid) modify(u << 1, l, mid, x, y, id);
  if (y > mid) modify(u << 1 | 1, mid + 1, r, x, y, id);
}
inline int findf(int x) {
  while (x != fa[x]) x = fa[x];
  return x;
}
inline int getdis(int x) { return fa[x] == x ? 0 : fdis[x] ^ getdis(fa[x]); }
void solve(int u, int l, int r, BASIS b) {
  stack<pair<int, int> > st;
  for (const auto &i : wife[u]) {
    int x = findf(e[i].u), y = findf(e[i].v), w = e[i].w;
    w ^= getdis(e[i].u) ^ getdis(e[i].v);
    if (x == y)
      b.insert(w);
    else {
      if (dep[x] > dep[y]) swap(x, y);
      st.push(make_pair(x, dep[x] == dep[y]));
      fa[x] = y;
      fdis[x] = w;
      dep[y] += (dep[x] == dep[y]);
    }
  }
  if (l == r)
    printf("%d\n", b.query(getdis(qx[l]) ^ getdis(qy[l])));
  else {
    int mid = (l + r) >> 1;
    solve(u << 1, l, mid, b);
    solve(u << 1 | 1, mid + 1, r, b);
  }
  pair<int, int> x;
  while (!st.empty()) {
    x = st.top();
    fdis[x.first] = 0;
    dep[fa[x.first]] -= x.second;
    fa[x.first] = x.first;
    st.pop();
  }
}
int main() {
  int u, v, w, q, opt;
  read(n);
  read(m);
  for (int i = 1; i <= n; ++i) fa[i] = i;
  ecnt = m;
  lim = 1;
  for (int i = 1; i <= m; ++i) {
    read(e[i].u);
    read(e[i].v);
    read(e[i].w);
    eus[make_pair(e[i].u, e[i].v)] = i;
    e[i].l = 1;
    e[i].r = -1;
  }
  read(q);
  while (q--) {
    read(opt);
    read(u);
    read(v);
    if (opt == 1) {
      read(w);
      e[++ecnt].u = u;
      e[ecnt].v = v;
      e[ecnt].w = w;
      e[ecnt].l = lim;
      e[ecnt].r = -1;
      eus[make_pair(u, v)] = ecnt;
    } else if (opt == 2)
      e[eus[make_pair(u, v)]].r = lim - 1;
    else
      qx[lim] = u, qy[lim] = v, ++lim;
  }
  --lim;
  for (int i = 1; i <= ecnt; ++i)
    if (e[i].r == -1) e[i].r = lim;
  for (int i = 1; i <= ecnt; ++i)
    if (e[i].l <= e[i].r) modify(1, 1, lim, e[i].l, e[i].r, i);
  solve(1, 1, lim, preb);
  return 0;
}