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 gi() {
  int x = 0, w = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') w = 0, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return w ? x : -x;
}
const int N = 2e5 + 5;
struct edge {
  int u, v, w, l, r;
} E[N << 1];
struct query {
  int u, v;
} q[N];
struct mdf {
  int x, y, sz;
} s[N << 1];
int n, m, tot, fa[N], sz[N], tag[N], top;
vector<int> v[N << 2];
map<pair<int, int>, int> M;
struct xxj {
  int p[31];
  void insert(int x) {
    for (int j = 30; ~j; --j)
      if ((x >> j) & 1) {
        if (!p[j]) {
          p[j] = x;
          return;
        }
        x ^= p[j];
      }
  }
  int calc(int x) {
    for (int j = 30; ~j; --j) x = min(x, x ^ p[j]);
    return x;
  }
} tmp;
void modify(int x, int l, int r, int ql, int qr, int i) {
  if (l >= ql && r <= qr) {
    v[x].push_back(i);
    return;
  }
  int mid = l + r >> 1;
  if (ql <= mid) modify(x << 1, l, mid, ql, qr, i);
  if (qr > mid) modify(x << 1 | 1, mid + 1, r, ql, qr, i);
}
pair<int, int> find(int x) {
  int d = 0;
  while (x != fa[x]) d ^= tag[x], x = fa[x];
  return make_pair(x, d);
}
void dfs(int x, int l, int r, xxj S) {
  int tt = top;
  for (auto i : v[x]) {
    pair<int, int> x = find(E[i].u), y = find(E[i].v);
    if (x.first == y.first) {
      S.insert(x.second ^ y.second ^ E[i].w);
      continue;
    }
    if (sz[x.first] > sz[y.first]) swap(x, y);
    s[++top] = (mdf){x.first, y.first, sz[y.first]};
    fa[x.first] = y.first;
    sz[y.first] += sz[x.first];
    tag[x.first] = x.second ^ y.second ^ E[i].w;
  }
  if (l == r) {
    pair<int, int> x = find(q[l].u), y = find(q[l].v);
    printf("%d\n", S.calc(x.second ^ y.second));
  } else {
    int mid = l + r >> 1;
    dfs(x << 1, l, mid, S);
    dfs(x << 1 | 1, mid + 1, r, S);
  }
  while (top > tt) {
    int x = s[top].x, y = s[top].y;
    tag[x] = 0;
    fa[x] = x;
    sz[y] = s[top].sz;
    --top;
  }
}
int main() {
  n = gi();
  m = gi();
  for (int i = 1; i <= m; ++i) {
    int u = gi(), v = gi(), w = gi();
    if (u > v) swap(u, v);
    E[i] = (edge){u, v, w, 1, -1};
    M[make_pair(u, v)] = i;
  }
  int Case = gi();
  while (Case--) {
    int op = gi();
    if (op == 1) {
      int u = gi(), v = gi(), w = gi();
      if (u > v) swap(u, v);
      E[++m] = (edge){u, v, w, tot + 1, -1};
      M[make_pair(u, v)] = m;
    } else if (op == 2) {
      int u = gi(), v = gi();
      if (u > v) swap(u, v);
      E[M[make_pair(u, v)]].r = tot;
      M.erase(make_pair(u, v));
    } else {
      int u = gi(), v = gi();
      q[++tot] = (query){u, v};
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (E[i].r == -1) E[i].r = tot;
    if (E[i].l <= E[i].r) modify(1, 1, tot, E[i].l, E[i].r, i);
  }
  for (int i = 1; i <= n; ++i) fa[i] = i, sz[i] = 1;
  dfs(1, 1, tot, tmp);
  return 0;
}