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;
struct node {
  int x, y, v;
};
int lb[400100 * 4][32], fa[400100], siz[400100], v[400100], i, n, m, o, p, w,
    op, q;
map<pair<int, int>, pair<int, int> > e;
pair<int, int> que[400100];
vector<node> s[400100 * 4];
void insert(int rt, int l, int r, int x, int y, node t) {
  if (x <= l && r <= y) {
    s[rt].push_back(t);
    return;
  }
  if (x <= ((l + r) / 2)) insert((rt << 1), l, ((l + r) / 2), x, y, t);
  if (y >= ((l + r) / 2) + 1)
    insert((rt << 1 | 1), ((l + r) / 2) + 1, r, x, y, t);
}
void add(int *lb, int x) {
  for (int i = 30; i >= 0; i--) {
    if (x & (1 << i)) {
      if (lb[i] == 0) {
        lb[i] = x;
        break;
      } else
        x ^= lb[i];
    }
  }
}
pair<int, int> find(int x) {
  int ret = 0;
  while (x != fa[x]) {
    ret ^= v[x];
    x = fa[x];
  }
  return make_pair(x, ret);
}
void dfs(int rt, int l, int r) {
  for (i = 0; i <= 30; i++) lb[rt][i] = lb[rt / 2][i];
  for (auto &a : s[rt]) {
    auto x = find(a.x), y = find(a.y);
    if (x.first == y.first) {
      add(lb[rt], x.second ^ y.second ^ a.v), a.v = -1;
    } else {
      if (siz[x.first] < siz[y.first]) swap(x, y);
      fa[y.first] = x.first, siz[x.first] += siz[y.first];
      v[y.first] = x.second ^ y.second ^ a.v;
      a.x = x.first, a.y = y.first;
    }
  }
  if (l == r) {
    if (que[l].first != 0) {
      auto x = find(que[l].first), y = find(que[l].second);
      int ans = x.second ^ y.second;
      for (int i = 30; i >= 0; i--) ans = min(ans, ans ^ lb[rt][i]);
      printf("%d\n", ans);
    }
    return;
  }
  dfs((rt << 1), l, ((l + r) / 2));
  dfs((rt << 1 | 1), ((l + r) / 2) + 1, r);
  for (auto a : s[rt]) {
    if (a.v == -1) continue;
    auto x = a.x, y = a.y;
    fa[y] = y;
    siz[x] -= siz[y];
    v[y] = 0;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) fa[i] = i, siz[i] = 1;
  for (i = 1; i <= m; i++) {
    scanf("%d %d %d", &o, &p, &w);
    if (o > p) swap(o, p);
    e[make_pair(o, p)] = make_pair(1, w);
  }
  scanf("%d", &q);
  for (i = 1; i <= q; i++) {
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d %d %d", &o, &p, &w);
      if (o > p) swap(o, p);
      e[make_pair(o, p)] = make_pair(i, w);
    } else if (op == 2) {
      scanf("%d %d", &o, &p);
      if (o > p) swap(o, p);
      auto a = e[make_pair(o, p)];
      e.erase(make_pair(o, p));
      node t = (node){o, p, a.second};
      insert(1, 1, q, a.first, i, t);
    } else {
      scanf("%d %d", &o, &p);
      que[i] = make_pair(o, p);
    }
  }
  for (auto a : e) {
    node t = (node){a.first.first, a.first.second, a.second.second};
    insert(1, 1, q, a.second.first, q, t);
  }
  dfs(1, 1, q);
}