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>
namespace my_std {
using namespace std;
template <typename T>
inline void read(T& t) {
  t = 0;
  char f = 0, ch = getchar();
  double d = 0.1;
  while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
  while (ch <= '9' && ch >= '0') t = t * 10 + ch - 48, ch = getchar();
  if (ch == '.') {
    ch = getchar();
    while (ch <= '9' && ch >= '0') t += d * (ch ^ 48), d *= 0.1, ch = getchar();
  }
  t = (f ? -t : t);
}
template <typename T, typename... Args>
inline void read(T& t, Args&... args) {
  read(t);
  read(args...);
}
void file() {}
}  // namespace my_std
using namespace my_std;
int n, m, Q;
map<pair<int, int>, int> M;
struct hh {
  int f, t, w;
  hh(int ff = 0, int tt = 0, int ww = 0) { f = ff, t = tt, w = ww; }
} edge[202020 << 1];
int bg[202020 << 1], ed[202020 << 1];
struct HH {
  int w[34];
  void ins(int x) {
    for (int i = (30); i >= (0); i--)
      if (x & (1 << i)) {
        if (!w[i]) return (void)(w[i] = x);
        x ^= w[i];
      }
  }
  int query(int x) {
    for (int i = (30); i >= (0); i--)
      if ((x ^ w[i]) < x) x ^= w[i];
    return x;
  }
} _;
vector<hh> v[202020 << 2];
void insert(int k, int l, int r, int x, int y, hh e) {
  if (x <= l && r <= y) return (void)v[k].push_back(e);
  int mid = (l + r) >> 1;
  if (x <= mid) insert(k << 1, l, mid, x, y, e);
  if (y > mid) insert(k << 1 | 1, mid + 1, r, x, y, e);
}
int qx[202020], qy[202020];
int fa[202020], f[202020], dep[202020];
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]); }
struct hhh {
  int x, y;
  bool s;
};
void solve(int k, int l, int r, HH G) {
  stack<hhh> S;
  for (int i = (0); i <= ((int)v[k].size() - 1); i++) {
    int x = v[k][i].f, y = v[k][i].t, w = v[k][i].w;
    int fx = getfa(x), fy = getfa(y);
    w ^= getdis(x) ^ getdis(y);
    if (fx == fy)
      G.ins(w);
    else {
      if (dep[fx] > dep[fy]) swap(fx, fy), swap(x, y);
      hhh cur = (hhh){fx, fy, 0};
      fa[fx] = fy;
      f[fx] = w;
      if (dep[fx] == dep[fy]) ++dep[fy], cur.s = 1;
      S.push(cur);
    }
  }
  if (l == r)
    printf("%d\n", G.query(getdis(qx[l]) ^ getdis(qy[l])));
  else {
    int mid = (l + r) >> 1;
    solve(k << 1, l, mid, G);
    solve(k << 1 | 1, mid + 1, r, G);
  }
  while (!S.empty())
    f[fa[S.top().x] = S.top().x] = 0, dep[S.top().y] -= S.top().s, S.pop();
}
int main() {
  file();
  int x, y, z;
  read(n, m);
  for (int i = (1); i <= (n); i++) fa[i] = i;
  int c = m, tim = 1;
  for (int i = (1); i <= (m); i++)
    read(x, y, z), M[make_pair(x, y)] = i, bg[i] = 1, ed[i] = -1,
                                  edge[i] = hh(x, y, z);
  read(Q);
  for (int i = (1); i <= (Q); i++) {
    read(z, x, y);
    if (z == 1) {
      read(z);
      M[make_pair(x, y)] = ++c;
      bg[c] = tim;
      ed[c] = -1;
      edge[c] = hh(x, y, z);
    } else if (z == 2)
      ed[M[make_pair(x, y)]] = tim - 1;
    else
      qx[tim] = x, qy[tim] = y, ++tim;
  }
  --tim;
  for (int i = (1); i <= (c); i++)
    if (ed[i] == -1) ed[i] = tim;
  for (int i = (1); i <= (c); i++)
    if (bg[i] <= ed[i]) insert(1, 1, tim, bg[i], ed[i], edge[i]);
  solve(1, 1, tim, _);
  return 0;
}