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>
#pragma GCC optimize("Ofast")
using namespace std;
void fio() {}
void pti() {
  double timeuse = clock() * 1000.0 / CLOCKS_PER_SEC;
  cerr << "Timeuse " << timeuse << "ms" << endl;
}
void end() {
  pti();
  exit(0);
}
namespace io {
const int SIZ = 55;
int que[SIZ], op, qr;
char ch;
template <class I>
inline void gi(I& w) {
  ch = getchar(), op = 1, w = 0;
  while (!isdigit(ch)) {
    if (ch == '-') op = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    w = w * 10 + ch - '0';
    ch = getchar();
  }
  w *= op;
}
template <typename T, typename... Args>
inline void gi(T& t, Args&... args) {
  gi(t);
  gi(args...);
}
template <class I>
inline void print(I w) {
  qr = 0;
  if (!w) putchar('0');
  if (w < 0) putchar('-'), w = -w;
  while (w) que[++qr] = w % 10 + '0', w /= 10;
  while (qr) putchar(que[qr--]);
}
}  // namespace io
using io::gi;
using io::print;
const int N = 2e5 + 5;
struct edge {
  int u, v, w;
};
struct node {
  int x, y;
  bool operator<(const node& a) const { return (x == a.x) ? y < a.y : x < a.x; }
};
struct rt {
  int p[32];
  void insert(int x) {
    for (int i = 29; i >= 0; --i) {
      if (!((x >> i) & 1)) continue;
      if (!p[i]) {
        p[i] = x;
        break;
      }
      x ^= p[i];
    }
  }
  int query(int x) {
    for (int i = 29; i >= 0; --i)
      if ((x ^ p[i]) < x) x ^= p[i];
    return x;
  }
} sr;
int n, m, q, top, sig;
int anc[N], dis[N], d[N], be[N << 1], ed[N << 1];
int qu[N], qv[N];
edge e[N << 1];
vector<int> t[N << 2];
node stk[N << 4];
bool isq[N];
map<node, int> s;
void update(int x, int y, int l, int r, int i, int o) {
  if (l >= x && r <= y) {
    t[o].push_back(i);
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid) update(x, y, l, mid, i, o << 1);
  if (y > mid) update(x, y, mid + 1, r, i, o << 1 | 1);
}
void undo() {
  int x = stk[top].x, y = stk[top].y;
  --top;
  d[anc[x]] -= y, anc[x] = x, dis[x] = 0;
}
int find(int x) {
  if (anc[x] == x) return x;
  return find(anc[x]);
}
int getdis(int x) {
  if (anc[x] == x) return 0;
  return dis[x] ^ getdis(anc[x]);
}
void solve(int l, int r, int o, rt g) {
  int num = top;
  for (auto i : t[o]) {
    int u = e[i].u, v = e[i].v, w = e[i].w;
    int fx = find(u), fy = find(v);
    w ^= getdis(u) ^ getdis(v);
    if (fx == fy)
      g.insert(w);
    else {
      if (d[fx] > d[fy]) swap(fx, fy);
      anc[fx] = fy, dis[fx] = w, d[fy] += d[fx] == d[fy];
      stk[++top] = {fx, d[fx] == d[fy]};
    }
  }
  if (l == r) {
    if (isq[l]) {
      int t = getdis(qu[l]) ^ getdis(qv[l]);
      print(g.query(t)), putchar(10);
    }
  } else {
    int mid = (l + r) >> 1;
    solve(l, mid, o << 1, g), solve(mid + 1, r, o << 1 | 1, g);
  }
  while (top > num) undo();
}
int main() {
  fio();
  gi(n, m);
  for (int i = 1; i <= m; ++i) gi(e[i].u, e[i].v, e[i].w);
  gi(q);
  for (int i = 1; i <= m; ++i) be[i] = 1, ed[i] = q, s[{e[i].u, e[i].v}] = i;
  for (int i = 1, op, x, y, z; i <= q; ++i) {
    gi(op, x, y);
    if (op == 1) {
      gi(z), ++m;
      e[m].u = x, e[m].v = y, e[m].w = z;
      be[m] = i, ed[m] = q, s[{x, y}] = m;
    } else if (op == 2)
      ed[s[{x, y}]] = i - 1;
    else {
      isq[i] = true;
      qu[i] = x, qv[i] = y;
    }
  }
  for (int i = 1; i <= m; ++i)
    if (be[i] <= ed[i]) update(be[i], ed[i], 1, q, i, 1);
  for (int i = 1; i <= n; ++i) anc[i] = i;
  solve(1, q, 1, sr);
  end();
}