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 = 200005;
template <typename T>
inline void read(T &AKNOI) {
  T x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  AKNOI = flag * x;
}
int n, m, q, qu[MAXN], qv[MAXN], qcnt;
map<int, int> id[MAXN];
struct Edge {
  int u, v, w, l, r;
  Edge() {}
  Edge(int _u, int _v, int _w, int _l, int _r)
      : u(_u), v(_v), w(_w), l(_l), r(_r) {}
} e[MAXN << 1];
vector<int> seg[MAXN << 2];
int f[MAXN], siz[MAXN], tag[MAXN], stk[MAXN << 1], top;
struct LinearBase {
  int base[30];
  inline void Insert(int x) {
    for (int i = 29; ~i; --i) {
      if ((x >> i) & 1) {
        if (!base[i]) {
          base[i] = x;
          return;
        }
        x ^= base[i];
      }
    }
  }
  inline int Query(int x) {
    for (int i = 29; ~i; --i) {
      x = min(x, x ^ base[i]);
    }
    return x;
  }
} I;
inline int getf(int x) {
  while (x ^ f[x]) {
    x = f[x];
  }
  return x;
}
inline int getv(int x) {
  int ret = 0;
  while (x ^ f[x]) {
    ret ^= tag[x];
    x = f[x];
  }
  return ret;
}
void Insert(int rt, int b, int e, int l, int r, int v) {
  if (l <= b && e <= r) {
    seg[rt].push_back(v);
    return;
  }
  int mid = (b + e) >> 1;
  if (l <= mid) Insert((rt << 1), b, mid, l, r, v);
  if (r > mid) Insert((rt << 1) | 1, mid + 1, e, l, r, v);
}
void Work(int rt, int l, int r, LinearBase B) {
  int cur = top;
  for (auto i : seg[rt]) {
    int u = getf(e[i].u), v = getf(e[i].v);
    int x = getv(e[i].u), y = getv(e[i].v);
    if (u == v) {
      B.Insert(x ^ y ^ e[i].w);
    } else {
      if (siz[u] < siz[v]) swap(u, v);
      f[v] = u;
      siz[u] += siz[v];
      tag[v] = (x ^ y ^ e[i].w);
      stk[++top] = v;
    }
  }
  if (l == r) {
    printf("%d\n", B.Query(getv(qu[l]) ^ getv(qv[r])));
  } else {
    int mid = (l + r) >> 1;
    Work((rt << 1), l, mid, B);
    Work((rt << 1) | 1, mid + 1, r, B);
  }
  for (; top > cur; --top) {
    int u = stk[top];
    tag[u] = 0;
    siz[f[u]] -= siz[u];
    f[u] = u;
  }
}
void solve() {
  read(n);
  read(m);
  for (int i = 1, u, v, w; i <= m; ++i) {
    read(u);
    read(v);
    read(w);
    if (u > v) swap(u, v);
    id[u][v] = i;
    e[i] = Edge(u, v, w, 1, -1);
  }
  read(q);
  for (int i = 1, op, u, v, w; i <= q; ++i) {
    read(op);
    read(u);
    read(v);
    if (u > v) swap(u, v);
    if (op == 1) {
      read(w);
      id[u][v] = ++m;
      e[m] = Edge(u, v, w, qcnt + 1, -1);
    } else if (op == 2) {
      e[id[u][v]].r = qcnt;
      id[u].erase(v);
    } else if (op == 3) {
      qu[++qcnt] = u;
      qv[qcnt] = v;
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (e[i].r < 0) e[i].r = qcnt;
    if (e[i].l <= e[i].r) {
      Insert(1, 1, qcnt, e[i].l, e[i].r, i);
    }
  }
  for (int i = 1; i <= n; ++i) {
    f[i] = i;
    siz[i] = 1;
  }
  Work(1, 1, qcnt, I);
}
int main() {
  solve();
  return 0;
}