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() {
  char ch = 0;
  int x = 0, flag = 1;
  while (!isdigit(ch)) {
    ch = getchar();
    if (ch == '-') flag = -1;
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * flag;
}
struct link {
  int x, y, z;
};
bool operator<(link a, link b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
map<link, int> S;
map<link, int>::iterator it;
int n, m, qnum, now, cnt, tot, ans[440000];
struct ques {
  int x, y, id;
} q[440000];
struct node {
  link s;
  int l, r;
} p[440000 * 2];
int top, f[440000], v[440000], sz[440000], sk[6600000];
int find(int x) {
  if (x != f[x])
    return find(f[x]);
  else
    return f[x];
}
int value(int x) {
  if (x != f[x])
    return value(f[x]) ^ v[x];
  else
    return 0;
}
bool merge(link s) {
  int a = s.x, b = s.y, x = find(a), y = find(b), z = s.z;
  if (x == y) return false;
  if (sz[x] > sz[y]) swap(x, y), swap(a, b);
  v[x] = 0;
  v[x] = value(a) ^ value(b) ^ z;
  f[x] = y;
  sz[y] += sz[x];
  sk[++top] = x;
  return true;
}
void erase() {
  int x = sk[top--];
  sz[f[x]] -= sz[x];
  f[x] = x;
  v[x] = 0;
}
struct pot {
  int s[33];
  void insert(int x) {
    for (int i = 31; i >= 0; i--)
      if (1 << i & x) {
        if (!s[i]) {
          s[i] = x;
          break;
        } else
          x ^= s[i];
      }
  }
  int query(int x) {
    for (int i = 31; i >= 0; i--)
      if (1 << i & x) x ^= s[i];
    return x;
  }
} sp[200];
vector<link> V[440000 * 4];
void optset(int o, int l, int r, int ql, int qr, link s) {
  if (ql <= l && r <= qr) {
    V[o].push_back(s);
    return;
  }
  if (ql <= ((l + r) >> 1)) optset(o << 1, l, ((l + r) >> 1), ql, qr, s);
  if (qr > ((l + r) >> 1)) optset(o << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr, s);
}
void solve(int o, int l, int r, int t) {
  if (l > r) return;
  int times = 0, len = V[o].size();
  for (int i = 0; i < len; i++)
    if (merge(V[o][i]))
      times++;
    else
      sp[t].insert(value(V[o][i].x) ^ value(V[o][i].y) ^ V[o][i].z);
  if (l == r) {
    while (now < tot && q[now + 1].id == l) {
      now++;
      ans[q[now].id] = sp[t].query(value(q[now].x) ^ value(q[now].y));
    }
  } else {
    for (int i = 31; i >= 0; i--) sp[t + 1].s[i] = sp[t].s[i];
    solve(o << 1, l, ((l + r) >> 1), t + 1);
    for (int i = 31; i >= 0; i--) sp[t + 1].s[i] = sp[t].s[i];
    solve(o << 1 | 1, ((l + r) >> 1) + 1, r, t + 1);
  }
  for (int i = 0; i < times; i++) erase();
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    link o;
    o.x = read();
    o.y = read();
    o.z = read();
    if (o.x > o.y) swap(o.x, o.y);
    S.insert(pair<link, int>(o, 0));
  }
  qnum = read();
  for (int i = 1; i <= qnum; i++) {
    int flag = read();
    if (flag == 1) {
      link o;
      o.x = read();
      o.y = read();
      o.z = read();
      if (o.x > o.y) swap(o.x, o.y);
      S.insert(pair<link, int>(o, i));
    }
    if (flag == 2) {
      link o;
      o.x = read();
      o.y = read();
      it = S.find(o);
      p[++cnt] = (node){it->first, it->second, i};
      S.erase(it);
    }
    if (flag == 3) {
      q[++tot].id = i;
      q[tot].x = read();
      q[tot].y = read();
      if (q[tot].x > q[tot].y) swap(q[tot].x, q[tot].y);
    }
  }
  for (it = S.begin(); it != S.end(); it++)
    p[++cnt] = (node){it->first, it->second, m};
  for (int i = 1; i <= cnt; i++) optset(1, 0, qnum, p[i].l, p[i].r, p[i].s);
  for (int i = 1; i <= n; i++) f[i] = i, v[i] = 0, sz[i] = 1;
  solve(1, 0, m, 1);
  for (int i = 1; i <= tot; i++) printf("%d\n", ans[q[i].id]);
  return 0;
}