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 <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long loo = 1ll << 62;
const int mods = 998244353;
const int MAXN = 1000005;
const int INF = 0x3f3f3f3f;
inline int read() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
map<pair<int, int>, pair<int, int> > Map;
int n, m, base[30], btop = 0, bstk[MAXN], f[MAXN], num[MAXN], d[MAXN],
                    Ans[MAXN], utop = 0;
struct ustknode {
  int u, v, c;
} ustk[MAXN];
struct Cnode {
  int x, y, c;
};
struct Qnode {
  int id, x, y;
};
vector<Cnode> C[MAXN];
vector<Qnode> Q[MAXN];
void insert(int x) {
  for (int i = 29; i >= 0; --i)
    if ((x >> i) & 1) {
      if (!base[i]) {
        base[i] = x, bstk[++btop] = i;
        return;
      }
      x ^= base[i];
    }
}
int getmn(int x) {
  for (int i = 29; i >= 0; --i) upmin(x, x ^ base[i]);
  return x;
}
int find(int x) { return f[x] == x ? f[x] : find(f[x]); }
int getdis(int x) { return f[x] == x ? d[x] : getdis(f[x]) ^ d[x]; }
void unions(int u, int v, int c) {
  if (num[u] < num[v]) swap(u, v);
  ustk[++utop] = (ustknode){u, v, c}, f[v] = u, d[v] ^= c, num[u] += num[v];
}
void update(int x, int l, int r, int L, int R, Cnode y) {
  if (l >= L && r <= R) {
    C[x].push_back(y);
    return;
  }
  int mid = (l + r) >> 1;
  if (R <= mid)
    update(x << 1, l, mid, L, R, y);
  else if (L > mid)
    update(x << 1 | 1, mid + 1, r, L, R, y);
  else
    update(x << 1, l, mid, L, mid, y),
        update(x << 1 | 1, mid + 1, r, mid + 1, R, y);
}
void solve(int x, int l, int r) {
  int blst = btop, ulst = utop;
  for (auto t : C[x]) {
    int u = t.x, v = t.y, c = t.c, uu = find(u), vv = find(v);
    if (uu == vv)
      insert(getdis(u) ^ getdis(v) ^ c);
    else
      unions(uu, vv, getdis(u) ^ getdis(v) ^ c);
  }
  if (l == r) {
    for (auto t : Q[l]) Ans[t.id] = getmn(getdis(t.x) ^ getdis(t.y));
  } else {
    int mid = (l + r) >> 1;
    solve(x << 1, l, mid);
    solve(x << 1 | 1, mid + 1, r);
  }
  while (btop > blst) base[bstk[btop--]] = 0;
  while (utop > ulst)
    num[ustk[utop].u] -= num[ustk[utop].v],
        f[ustk[utop].v] = ustk[utop].v, d[ustk[utop].v] ^= ustk[utop].c, --utop;
}
signed main() {
  n = read(), m = read();
  for (int i = 1; i <= n; ++i) num[i] = 1, f[i] = i;
  for (int i = 1; i <= m; ++i) {
    int u = read(), v = read(), c = read();
    Map[make_pair(u, v)] = make_pair(0, c);
  }
  int Case = read(), num = 0;
  for (int i = 1; i <= Case; ++i) {
    int opt = read(), x = read(), y = read(), c;
    if (opt == 1) c = read(), Map[make_pair(x, y)] = make_pair(i, c);
    if (opt == 2)
      update(1, 0, m, Map[make_pair(x, y)].first, i,
             (Cnode){x, y, Map[make_pair(x, y)].second}),
          Map.erase(make_pair(x, y));
    if (opt == 3) Q[i].push_back(((Qnode){++num, x, y}));
  }
  for (auto t : Map)
    update(1, 0, m, t.second.first, m,
           (Cnode){t.first.first, t.first.second, t.second.second});
  solve(1, 0, m);
  for (int i = 1; i <= num; ++i) printf("%d\n", Ans[i]);
  return 0;
}