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>
const int oo = 2139063143;
const int N = 1010000;
const int P = 1000000007;
using namespace std;
char buf[1 << 24], *p1 = buf, *p2 = buf, obuf[1 << 23], *O = obuf;
inline void sc(int &x) {
  x = 0;
  static int p;
  p = 1;
  static char c;
  c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
           ? EOF
           : *p1++);
  while (!isdigit(c)) {
    if (c == '-') p = -1;
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - 48);
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  x *= p;
}
inline void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
inline void pr(int x) { print(x), putchar('\n'); }
int b[35];
int ins(int x) {
  for (int i = 30; i >= 0; i--)
    if (x >> i & 1) {
      if (!b[i]) {
        b[i] = x;
        return i;
      }
      x ^= b[i];
    }
  return 33;
}
int query(int x) {
  for (int i = 30; i >= 0; i--) x = min(x, x ^ b[i]);
  return x;
}
int fa[N], dis[N], siz[N];
int getdis(int &x) {
  int ans = 0;
  while (x != fa[x]) ans ^= dis[x], x = fa[x];
  return ans;
}
struct LY {
  int x, y, w;
};
vector<LY> v[N << 2];
int vis[N];
int ax[N], ay[N];
void update(int p, int L, int R, int l, int r, LY x) {
  if (l <= L && R <= r) {
    v[p].push_back(x);
    return;
  }
  int mid = (L + R) >> 1, ls = p << 1, rs = ls | 1;
  if (l <= mid) update(ls, L, mid, l, r, x);
  if (r > mid) update(rs, mid + 1, R, l, r, x);
}
int ans[N];
int st[N], z;
void del(int l) {
  while (z >= l) b[st[z--]] = 0;
}
int xx[N], yy[N], zz;
void dell(int l) {
  while (zz >= l)
    siz[fa[xx[zz]]] -= siz[xx[zz]], fa[xx[zz]] = xx[zz], dis[xx[zz]] = 0, --zz;
}
void solve(int p, int l, int r) {
  if (!(vis[r] - vis[l - 1])) return;
  int he1 = z + 1, he2 = zz + 1;
  for (int i = 0; i < (int)v[p].size(); i++) {
    int x = v[p][i].x, y = v[p][i].y, w = v[p][i].w;
    int dx = getdis(x), dy = getdis(y);
    if (x == y) {
      st[++z] = ins(dx ^ dy ^ w);
      continue;
    }
    if (siz[x] > siz[y]) swap(x, y), swap(dx, dy);
    fa[x] = y, dis[x] = dx ^ dy ^ w, siz[y] += siz[x];
    xx[++zz] = x, yy[zz] = y;
  }
  if (l == r) {
    int dx = getdis(ax[l]), dy = getdis(ay[l]);
    ans[l] = query(dx ^ dy);
    del(he1), dell(he2);
    return;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = ls | 1;
  solve(ls, l, mid);
  solve(rs, mid + 1, r);
  del(he1);
  dell(he2);
}
map<pair<int, int>, int> mp;
int las[N], su[N], sv[N];
int w[N], totw = 0;
int main() {
  int n, m;
  sc(n), sc(m);
  for (int i = 1; i <= n; i++) fa[i] = i, siz[i] = 1;
  for (int i = 1; i <= m; i++) {
    int u, v;
    sc(u), sc(v), sc(w[i]);
    mp[make_pair(u, v)] = i;
    su[i] = u, sv[i] = v;
  }
  totw = m;
  int q;
  sc(q);
  for (int i = 1; i <= q; i++) {
    int op, u, v;
    sc(op), sc(u), sc(v);
    if (op == 1)
      sc(w[++totw]), mp[make_pair(u, v)] = totw, las[totw] = i, su[totw] = u,
                                     sv[totw] = v;
    if (op == 2) {
      int bh = mp[make_pair(u, v)];
      update(1, 0, q, las[bh], i - 1, (LY){u, v, w[bh]}), las[bh] = -1;
    }
    if (op == 3) ++vis[i], ax[i] = u, ay[i] = v;
  }
  for (int i = 1; i <= totw; i++)
    if (las[i] != -1) update(1, 0, q, las[i], q, (LY){su[i], sv[i], w[i]});
  for (int i = 1; i <= q; i++) vis[i] += vis[i - 1];
  memset(ans, -1, sizeof(int) * (q + 1));
  solve(1, 0, q);
  for (int i = 1; i <= q; i++)
    if (ans[i] != -1) pr(ans[i]);
  return 0;
}