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;
pair<int, int> q[400010];
vector<pair<pair<int, int>, int> > o[800010];
map<int, int> d[200010], h[200010];
int num[35];
int top, n, m, T;
int cas[200010], x[200010], y[200010], z[200010], ans[200010];
int fa[200010], siz[200010], g[200010];
inline int read() {
  int ans = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
  return ans;
}
inline int find(int x) {
  if (fa[x] == x) return x;
  return find(fa[x]);
}
inline int findt(int x) {
  if (fa[x] == x) return 0;
  return g[x] ^ findt(fa[x]);
}
void ins(int x, int y, int z, int k) {
  if (x > y) swap(x, y);
  d[x][y] = k;
  h[x][y] = z;
}
void ins(int rex, int l, int r, int x, int y, pair<pair<int, int>, int> z) {
  if (l == x && r == y) {
    o[rex].push_back(z);
    return;
  }
  int mid = (l + r) >> 1;
  if (y <= mid)
    ins(rex + rex, l, mid, x, y, z);
  else if (x > mid)
    ins(rex + rex + 1, mid + 1, r, x, y, z);
  else
    ins(rex + rex, l, mid, x, mid, z),
        ins(rex + rex + 1, mid + 1, r, mid + 1, y, z);
}
void del(int x, int y, int k) {
  if (x > y) swap(x, y);
  ins(1, 0, T, d[x][y], k, make_pair(make_pair(x, y), h[x][y]));
  d[x].erase(y);
}
void add(int k) {
  for (int i = 29; i >= 0; i--)
    if (k >> i & 1) {
      if (!num[i]) {
        num[i] = k;
        return;
      } else
        k ^= num[i];
    }
}
void calc(int rex) {
  for (pair<pair<int, int>, int> u : o[rex]) {
    int x = u.first.first, y = u.first.second, z = u.second;
    int dx = find(x), dy = find(y);
    if (dx == dy)
      add(findt(x) ^ findt(y) ^ z);
    else {
      if (siz[dx] > siz[dy]) swap(dx, dy);
      g[dx] = z ^ findt(x) ^ findt(y);
      siz[dy] += siz[dx];
      fa[dx] = dy;
      q[++top] = make_pair(dx, dy);
    }
  }
}
void del(pair<int, int> num) {
  int x = num.first, y = num.second;
  siz[y] -= siz[x];
  fa[x] = x;
  g[x] = 0;
}
void solve(int rex, int l, int r) {
  calc(rex);
  if (l == r) {
    if (cas[l] == 3) {
      ans[l] = findt(x[l]) ^ findt(y[l]);
      for (int i = 29; i >= 0; i--)
        if (ans[l] >> i & 1) ans[l] ^= num[i];
    }
    return;
  }
  int mid = (l + r) >> 1;
  int tmp[30];
  int pos = top;
  for (int i = 0; i < 30; i++) tmp[i] = num[i];
  solve(rex + rex, l, mid);
  while (top > pos) del(q[top--]);
  for (int i = 0; i < 30; i++) num[i] = tmp[i];
  solve(rex + rex + 1, mid + 1, r);
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) fa[i] = i, siz[i] = 1;
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read(), z = read();
    ins(x, y, z, 0);
  }
  T = read();
  for (int i = 1; i <= T; i++) {
    cas[i] = read();
    if (cas[i] == 1)
      x[i] = read(), y[i] = read(), z[i] = read(), ins(x[i], y[i], z[i], i);
    else if (cas[i] == 2)
      x[i] = read(), y[i] = read(), del(x[i], y[i], i);
    else
      x[i] = read(), y[i] = read();
  }
  for (int i = 1; i <= n; i++) {
    vector<int> G;
    for (pair<int, int> t : d[i]) G.push_back(t.first);
    for (int v : G) del(i, v, T);
  }
  solve(1, 0, T);
  for (int i = 1; i <= T; i++)
    if (cas[i] == 3) printf("%d\n", ans[i]);
}