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>
inline long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
int EA[400010], EB[400010], ED[400010], ES[400010], ET[400010], E;
std::map<std::pair<int, int>, int> st;
int QX[400010], QY[400010];
int fa[200010], sz[200010], W[200010];
std::stack<std::pair<int*, int>> stk;
std::vector<int> QAQ[800010];
inline int hd(int& x) {
  int r = 0;
  while (x != fa[x]) r ^= W[x], x = fa[x];
  return r;
}
inline int Union(int x, int y, int d) {
  int wx = hd(x), wy = hd(y);
  if (x == y) return d ^ wx ^ wy;
  if (sz[x] < sz[y]) std::swap(x, y), std::swap(wx, wy);
  stk.push({&fa[y], fa[y]});
  stk.push({&sz[x], sz[x]});
  stk.push({&W[y], W[y]});
  fa[y] = x, sz[x] += sz[y];
  W[y] = wx ^ wy ^ d;
  return -1;
}
inline void Update(int x, int l, int r, const int& L, const int& R,
                   const int& i) {
  if (L <= l && r <= R) return QAQ[x].push_back(i);
  if (L <= ((l + r) >> 1)) Update(x << 1, l, ((l + r) >> 1), L, R, i);
  if (((l + r) >> 1) < R) Update(x << 1 | 1, ((l + r) >> 1) + 1, r, L, R, i);
}
int p[30], ans[200010];
inline void insert(int* p, int s) {
  for (int i = 29; ~i; --i)
    if ((s >> i) & 1) {
      if (p[i])
        s ^= p[i];
      else {
        p[i] = s;
        break;
      }
    }
}
inline void DFS(int x, int l, int r) {
  int _p[30], __p[30];
  memcpy(__p, p, sizeof p);
  memcpy(_p, p, sizeof p);
  int o = 0;
  for (int i : QAQ[x]) {
    int w = Union(EA[i], EB[i], ED[i]);
    if (~w)
      insert(_p, w);
    else
      o += 3;
  }
  if (l == r) {
    int d = hd(QX[l]) ^ hd(QY[l]);
    for (int i = 29; ~i; --i)
      if ((d >> i) & 1) d ^= _p[i];
    ans[l] = d;
  } else {
    memcpy(p, _p, sizeof _p);
    DFS(x << 1, l, ((l + r) >> 1));
    memcpy(p, _p, sizeof _p);
    DFS(x << 1 | 1, ((l + r) >> 1) + 1, r);
  }
  while (o--) *stk.top().first = stk.top().second, stk.pop();
  memcpy(p, __p, sizeof __p);
}
int main() {
  int n = gi(), m = gi(), now = 0;
  for (int i = 1; i <= m; ++i)
    EA[i] = gi(), EB[i] = gi(), ED[i] = gi(), ES[i] = 1, st[{EA[i], EB[i]}] = i;
  E = m;
  int q = gi(), o, x, y;
  while (q--) {
    o = gi(), x = gi(), y = gi();
    if (o == 1)
      ++E, EA[E] = x, EB[E] = y, ED[E] = gi(), ES[E] = now + 1, st[{x, y}] = E;
    else if (o == 2)
      ET[st[{x, y}]] = now, st.erase({x, y});
    else
      ++now, QX[now] = x, QY[now] = y;
  }
  for (auto i : st) ET[i.second] = now;
  for (int i = 1; i <= E; ++i)
    if (ES[i] <= ET[i]) Update(1, 1, now, ES[i], ET[i], i);
  for (int i = 1; i <= n; ++i) fa[i] = i, sz[i] = 1;
  if (now) DFS(1, 1, now);
  for (int i = 1; i <= now; ++i) printf("%d\n", ans[i]);
  return 0;
}