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;
template <class T>
T read() {
  T x = 0, w = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') w = -w;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * w;
}
template <class T>
T read(T& x) {
  return x = read<T>();
}
const int N = 200000 + 10;
struct edge {
  int u, v, w, l, r;
} e[N << 1];
vector<edge> g[N << 2];
map<pair<int, int>, int> mp;
int val[N], fa[N], siz[N];
int stk[N << 1], top;
void update(int x, int l, int r, const edge& e) {
  if (e.l > e.r) return;
  if (e.l <= l && r <= e.r) return g[x].push_back(e);
  int mid = (l + r) >> 1;
  if (e.l <= mid) update((x << 1), l, mid, e);
  if (e.r > mid) update((x << 1 | 1), mid + 1, r, e);
}
struct ask {
  int u, v;
} qst[N];
int bas[20][30];
int find_fa(int x) { return fa[x] == x ? x : find_fa(fa[x]); }
int find_val(int x) { return fa[x] == x ? 0 : val[x] ^ find_val(fa[x]); }
void insert(int x, int dep) {
  for (int i = 0; i < (int)g[x].size(); ++i) {
    int u = g[x][i].u, v = g[x][i].v, w = g[x][i].w;
    int fu = find_fa(u), fv = find_fa(v);
    if (fu != fv) {
      if (siz[fu] > siz[fv]) swap(fu, fv), swap(u, v);
      fa[fu] = fv, siz[fv] += siz[fu], val[fu] = find_val(u) ^ find_val(v) ^ w;
      stk[++top] = fu;
    } else {
      w ^= find_val(u) ^ find_val(v);
      for (int j = 29; j >= 0; --j)
        if (w >> j & 1) {
          if (!bas[dep][j]) {
            bas[dep][j] = w;
            break;
          }
          w ^= bas[dep][j];
        }
    }
  }
}
void reset(int to) {
  for (; top > to; --top) {
    int u = stk[top];
    siz[fa[u]] -= siz[u], val[u] = 0, fa[u] = u;
  }
}
void solve(int x, int l, int r, int dep) {
  int tmp = top;
  insert(x, dep);
  if (l == r) {
    int u = qst[l].u, v = qst[l].v;
    int ans = find_val(u) ^ find_val(v);
    for (int i = 29; i >= 0; --i)
      if (ans >> i & 1)
        if (bas[dep][i]) ans ^= bas[dep][i];
    printf("%d\n", ans);
    return reset(tmp);
  }
  int mid = (l + r) >> 1;
  copy(bas[dep], bas[dep] + 30, bas[dep + 1]), solve((x << 1), l, mid, dep + 1);
  copy(bas[dep], bas[dep] + 30, bas[dep + 1]),
      solve((x << 1 | 1), mid + 1, r, dep + 1);
  reset(tmp);
}
int main() {
  int n = read<int>(), m = read<int>();
  int ecnt = 0;
  for (int i = 1; i <= m; ++i) {
    int u = read<int>(), v = read<int>(), w = read<int>();
    e[++ecnt] = (edge){u, v, w, 1, -1}, mp[make_pair(u, v)] = ecnt;
  }
  int q = read<int>();
  int totq = 0;
  for (int i = 1; i <= q; ++i) {
    int opt = read<int>();
    if (opt == 1) {
      int x = read<int>(), y = read<int>(), d = read<int>();
      e[++ecnt] = (edge){x, y, d, totq + 1, -1}, mp[make_pair(x, y)] = ecnt;
    } else if (opt == 2) {
      int x = read<int>(), y = read<int>();
      e[mp[make_pair(x, y)]].r = totq, mp[make_pair(x, y)] = 0;
    } else {
      int x = read<int>(), y = read<int>();
      qst[++totq] = (ask){x, y};
    }
  }
  for (int i = 1; i <= ecnt; ++i) {
    if (e[i].r == -1) e[i].r = totq;
    update(1, 1, totq, e[i]);
  }
  for (int i = 1; i <= n; ++i) fa[i] = i, siz[i] = 1;
  solve(1, 1, totq, 0);
  return 0;
}