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 base {
  int b[33];
  void insert(int x) {
    for (int i = 30; i >= 0; i--)
      if ((x >> i) & 1) {
        if (!b[i]) {
          b[i] = x;
          return;
        }
        x ^= b[i];
      }
  }
  int query(int x) {
    for (int i = 30; i >= 0; i--)
      if ((x >> i) & 1) x ^= b[i];
    return x;
  }
} B;
struct node {
  int x, y, z, last;
  friend bool operator<(node a, node b) {
    return a.x == b.x ? a.y < b.y : a.x < b.x;
  }
} st[200005];
set<node> se;
int deep[200005], siz[200005], fa[200005], top, op[200005], a[200005],
    b[200005], c[200005];
vector<node> v[800005];
int find(int x) { return fa[x] == x ? x : find(fa[x]); }
int getd(int x) { return fa[x] == x ? 0 : (deep[x] ^ getd(fa[x])); }
void modify(int l, int r, int x, int a, int b, node t) {
  if (l >= a && r <= b) {
    v[x].push_back(t);
    return;
  }
  int mid = (l + r) >> 1;
  if (a <= mid) modify(l, mid, x * 2, a, b, t);
  if (b > mid) modify(mid + 1, r, x * 2 + 1, a, b, t);
}
void rollback() {
  int x = st[top].x, y = st[top].y;
  fa[x] = x, siz[y] -= siz[x], deep[x] = 0;
  top--;
}
void dfs(int l, int r, int x, base now) {
  int nw = top;
  for (auto i : v[x]) {
    int x = i.x, y = i.y, z = i.z, fx = find(x), fy = find(y);
    if (fx == fy)
      now.insert(getd(x) ^ getd(y) ^ z);
    else {
      if (siz[fx] > siz[fy]) swap(fx, fy);
      deep[fx] = (z ^ getd(x) ^ getd(y));
      fa[fx] = fy;
      siz[fy] += siz[fx];
      st[++top] = {fx, fy, 0, 0};
    }
  }
  if (l == r) {
    if (op[l] == 3) printf("%d\n", now.query(getd(a[l]) ^ getd(b[l])));
  } else {
    int mid = (l + r) >> 1;
    dfs(l, mid, x * 2, now);
    dfs(mid + 1, r, x * 2 + 1, now);
  }
  while (top > nw) rollback();
}
int main() {
  int n, m, q, x, y, z, tmp = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i, siz[i] = 1;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    if (i == 1) tmp = x;
    se.insert({x, y, z, 1});
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &op[i], &a[i], &b[i]);
    if (op[i] == 1) {
      scanf("%d", &c[i]);
      se.insert({a[i], b[i], c[i], i});
    } else if (op[i] == 2) {
      auto t = se.find({a[i], b[i], 0, 0});
      if (i != 1) modify(1, q, 1, t->last, i - 1, *t);
      se.erase(t);
    }
  }
  for (auto i : se) modify(1, q, 1, i.last, q, i);
  dfs(1, q, 1, B);
  return 0;
}