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;
inline int read() {
  int ch = getchar(), f = 0;
  int x = 0;
  while (ch < '0' || ch > '9') {
    f |= ch == '-';
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f ? -x : x;
}
struct eric {
  int to, from, v, start, end;
} edge[400005];
int tot, cnt;
int n, m;
int father[400005], siz[400005], d[400005], c[400005], dep[400005], ta[400005],
    tb[400005];
vector<int> seg[400005 << 2];
map<pair<int, int>, int> mp;
struct action {
  int fa, son, type;
} stak[400005];
int top;
struct liner_base {
  int a[32];
  inline void add(int x) {
    for (int i = 30; ~i; i--)
      if ((x >> i) & 1) {
        if (a[i])
          x ^= a[i];
        else {
          a[i] = x;
          break;
        }
      }
  }
  inline int get_min(int x) {
    for (int i = 30; ~i; i--) {
      if ((x ^ a[i]) < x) x ^= a[i];
    }
    return x;
  }
};
int find(int x) { return father[x] == x ? x : find(father[x]); }
int get_dis(int x) { return father[x] == x ? 0 : (get_dis(father[x]) ^ c[x]); }
inline void unionn(int a, int b, int v, liner_base& lb) {
  int t1 = find(a), t2 = find(b);
  d[a] = get_dis(a), d[b] = get_dis(b);
  if (t1 == t2) {
    lb.add(d[a] ^ d[b] ^ v);
    return;
  }
  if (dep[t1] < dep[t2]) swap(t1, t2), swap(a, b);
  c[t2] = d[a] ^ d[b] ^ v;
  father[t2] = t1;
  stak[++top] = (action){t1, t2, 0};
  if (dep[t1] == dep[t2]) dep[t1]++, stak[top].type = 1;
  return;
}
void modify(int pos, int l, int r, int nl, int nr, int id) {
  if (l >= nl && r <= nr) {
    seg[pos].push_back(id);
    return;
  }
  int mid = l + r >> 1;
  if (nl <= mid) modify(pos << 1, l, mid, nl, nr, id);
  if (nr > mid) modify(pos << 1 | 1, mid + 1, r, nl, nr, id);
}
void downpush(int pos, int l, int r, liner_base lb) {
  int beg = top;
  for (int i = 0, u; i < seg[pos].size(); i++) {
    u = seg[pos][i];
    unionn(edge[u].to, edge[u].from, edge[u].v, lb);
  }
  if (l == r) {
    d[ta[l]] = get_dis(ta[l]), d[tb[l]] = get_dis(tb[l]);
    printf("%d\n", lb.get_min(d[ta[l]] ^ d[tb[l]]));
    while (beg < top) {
      father[stak[top].son] = stak[top].son;
      dep[stak[top].fa] -= stak[top].type;
      top--;
    }
    return;
  }
  int mid = l + r >> 1;
  downpush(pos << 1, l, mid, lb);
  downpush(pos << 1 | 1, mid + 1, r, lb);
  while (beg < top) {
    father[stak[top].son] = stak[top].son;
    dep[stak[top].fa] -= stak[top].type;
    top--;
  }
}
int main() {
  n = read(), tot = read();
  for (int i = 1; i <= n; i++) father[i] = i, dep[i] = 1;
  cnt = 01;
  for (int i = 1; i <= tot; i++) {
    edge[i].from = read(), edge[i].to = read(), edge[i].v = read();
    edge[i].start = cnt;
    edge[i].end = -1;
    mp[make_pair(edge[i].from, edge[i].to)] = i;
    mp[make_pair(edge[i].to, edge[i].from)] = i;
  }
  m = read();
  for (int i = 1; i <= m; i++) {
    int opt = read();
    if (opt == 1) {
      edge[++tot].from = read(), edge[tot].to = read(), edge[tot].v = read();
      edge[tot].start = cnt;
      edge[tot].end = -1;
      mp[make_pair(edge[tot].from, edge[tot].to)] = tot;
      mp[make_pair(edge[tot].to, edge[tot].from)] = tot;
    } else if (opt == 2) {
      int first = read(), to = read(), k = mp[make_pair(first, to)];
      edge[k].end = cnt - 1;
    } else {
      ta[cnt] = read(), tb[cnt++] = read();
    }
  }
  cnt--;
  for (int i = 1; i <= tot; i++)
    if (edge[i].start <= edge[i].end)
      modify(1, 1, cnt, edge[i].start, edge[i].end, i);
    else if (edge[i].end == -1)
      modify(1, 1, cnt, edge[i].start, cnt, i);
  liner_base lb;
  memset(lb.a, 0, sizeof lb.a);
  downpush(1, 1, cnt, lb);
  return 0;
}