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;
const int N = 4e5 + 5, M = N * 20, Log = 30, T = 524295;
int n, m, q, tot, f[Log][Log], h[T], E[N][5], cnt, e[M], nxt[M], Ask, Q[N][2],
    Rank[N], sum[22], pr[22][N], pId[22][N];
pair<int, int> dsu[N], P[22][N];
map<long long, int> H;
char c;
int read() {
  int x = 0, sig = 1;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48;
  return x * sig;
}
void Add(int x, int y) {
  e[++tot] = y;
  nxt[tot] = h[x];
  h[x] = tot;
}
void Ins(int l, int r, int a, int b, int v, int x) {
  if (l == a && r == b) {
    Add(x, v);
    return;
  }
  int mid = l + r >> 1;
  if (b <= mid)
    Ins(l, mid, a, b, v, x << 1);
  else if (a > mid)
    Ins(mid + 1, r, a, b, v, x << 1 | 1);
  else {
    Ins(l, mid, a, mid, v, x << 1);
    Ins(mid + 1, r, mid + 1, b, v, x << 1 | 1);
  }
}
pair<int, int> Get(int x) {
  int t = 0;
  for (; dsu[x].first != x; x = dsu[x].first) t ^= dsu[x].second;
  return make_pair(x, t);
}
void Add_Loop(int x, int dep) {
  for (int i = Log - 1; i >= 0; i--)
    if (((1 << i) & x) > 0) {
      if (!f[dep][i]) {
        f[dep][i] = x;
        break;
      }
      x ^= f[dep][i];
    }
}
int getmin(int x, int dep) {
  for (int i = Log - 1; i >= 0; i--)
    if (((1 << i) & x) > 0) x ^= f[dep][i];
  return x;
}
void solve(int l, int r, int x, int dep) {
  for (int i = 0; i < Log; i++) f[dep][i] = f[dep - 1][i];
  sum[dep] = 0;
  pair<int, int> p, q, tmp;
  for (int i = h[x]; i; i = nxt[i]) {
    p = Get(E[e[i]][0]);
    q = Get(E[e[i]][1]);
    if (p.first == q.first)
      Add_Loop(E[e[i]][2] ^ p.second ^ q.second, dep);
    else {
      if (Rank[p.first] > Rank[q.first]) swap(p, q);
      P[dep][++sum[dep]] = dsu[p.first];
      pr[dep][sum[dep]] = Rank[p.first];
      pId[dep][sum[dep]] = p.first;
      P[dep][++sum[dep]] = dsu[q.first];
      pr[dep][sum[dep]] = Rank[q.first];
      pId[dep][sum[dep]] = q.first;
      dsu[p.first].first = q.first;
      dsu[p.first].second = p.second ^ q.second ^ E[e[i]][2];
      if (Rank[p.first] == Rank[q.first]) Rank[q.first]++;
    }
  }
  if (l == r) {
    p = Get(Q[l][0]);
    q = Get(Q[l][1]);
    printf("%d\n", getmin(p.second ^ q.second, dep));
  } else {
    int mid = l + r >> 1;
    solve(l, mid, x << 1, dep + 1);
    solve(mid + 1, r, x << 1 | 1, dep + 1);
  }
  for (int i = sum[dep]; i; i--) {
    int j = pId[dep][i];
    dsu[j] = P[dep][i];
    Rank[j] = pr[dep][i];
  }
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    E[i][0] = read();
    E[i][1] = read();
    E[i][2] = read();
    if (E[i][0] > E[i][1]) swap(E[i][0], E[i][1]);
    H[(long long)E[i][0] * (n + 1) + E[i][1]] = i;
    E[i][3] = 1;
  }
  for (q = read(); q--;) {
    int typ = read();
    if (typ == 1) {
      E[++m][0] = read();
      E[m][1] = read();
      E[m][2] = read();
      if (E[m][0] > E[m][1]) swap(E[m][0], E[m][1]);
      H[(long long)E[m][0] * (n + 1) + E[m][1]] = m;
      E[m][3] = Ask + 1;
    } else if (typ == 2) {
      int x = read(), y = read();
      if (x > y) swap(x, y);
      int i = H[(long long)x * (n + 1) + y];
      H[(long long)x * (n + 1) + y] = 0;
      E[i][4] = Ask;
    } else {
      Q[++Ask][0] = read();
      Q[Ask][1] = read();
    }
  }
  for (int i = 1; i <= m; i++) {
    if (H[(long long)E[i][0] * (n + 1) + E[i][1]] == i) E[i][4] = Ask;
    if (E[i][3] <= E[i][4]) Ins(1, Ask, E[i][3], E[i][4], i, 1);
  }
  tot = 0;
  for (int i = 1; i <= n; i++) dsu[i] = make_pair(i, 0), Rank[i] = 0;
  solve(1, Ask, 1, 1);
  return 0;
}