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>
const int N = 4e5 + 54, K = 29;
struct _ {
  int *p, v;
} st[N * 6];
int t;
void $(int& x, int y) { st[++t] = (_){&x, x}, x = y; }
int p[K + 5];
void I(int x) {
  for (int i = K, f; ~i; x ^= f * p[i--])
    if ((f = (x >> i) & 1) && !p[i]) return $(p[i], x);
}
int Q(int x) {
  for (int i = K; ~i; i--) x = std::min(x, x ^ p[i]);
  return x;
}
int _p[N], sz[N];
int xv[N], _t;
int f(int x, int& w = _t) {
  while (x[_p]) w ^= x[xv], x = x[_p];
  return x;
}
void M(int x, int y, int z) {
  _t = 0;
  if ((x = f(x)) != (y = f(y))) {
    if (x[sz] > y[sz]) std::swap(x, y);
    $(x[_p], y), $(y[sz], y[sz] + x[sz]), $(x[xv], z ^ _t);
  }
}
inline int Q(int x, int y) { return _t = 0, f(x), f(y), _t; }
inline void A(int a, int b, int c) {
  if (f(a) != f(b))
    M(a, b, c);
  else
    I(Q(a, b) ^ c);
}
int op[N], u[N], v[N], w[N], qu[N], qv[N];
std::vector<int> tr[N << 2];
int ql, qr;
void I(int x, int l, int r, int y) {
  if (ql <= l && r <= qr) return x[tr].push_back(y);
  if (ql <= (l + r) / 2) I((x << 1), l, (l + r) / 2, y);
  if ((l + r) / 2 < qr) I(((x << 1) | 1), (l + r) / 2 + 1, r, y);
}
void D(int x, int l, int r) {
  int sz = t;
  for (int i : x[tr]) A(u[i], v[i], w[i]);
  if (l == r)
    printf("%d\n", Q(Q(qu[l], qv[l])));
  else
    D((x << 1), l, (l + r) / 2), D(((x << 1) | 1), (l + r) / 2 + 1, r);
  for (; t > sz; t--) *st[t].p = st[t].v;
}
int n, m, m0, q, x, y, z, tm_lb[N], tm_rb[N];
int qry_lb[N], qry_rb[N], qc;
std::map<std::pair<int, int>, int> mp;
int main() {
  scanf("%d%d", &n, &m0), m += m0;
  for (int i = 1; i <= n; i++) i[sz] = 1;
  for (int i = 1; i <= m0; i++) {
    op[i] = 1, scanf("%d%d%d", u + i, v + i, w + i);
    mp[std::pair<int, int>(u[i], v[i])] = i;
  }
  scanf("%d", &m), m += m0;
  for (int i = m0 + 1; i <= m; i++) {
    scanf("%d%d%d", op + i, u + i, v + i);
    if (op[i] == 1) {
      scanf("%d", w + i);
      mp[std::pair<int, int>(u[i], v[i])] = i;
    }
    if (op[i] == 3) qc++, qu[qc] = u[i], qv[qc] = v[i];
    i[tm_rb] = qc;
  }
  for (int i = 1; i <= m; i++) i[qry_rb] = qc;
  for (int i = m, c = qc + 1; i >= 1; i--) i[tm_lb] = c -= (op[i] == 3);
  for (int i = 1; i <= m; i++) {
    if (op[i] == 1) i[qry_lb] = i[tm_lb];
    if (op[i] == 2) mp[std::pair<int, int>(u[i], v[i])][qry_rb] = i[tm_rb];
  }
  for (int i = 1; i <= m; i++) {
    if (op[i] == 1 && i[qry_lb] <= i[qry_rb])
      ql = i[qry_lb], qr = i[qry_rb], I(1, 1, qc, i);
  }
  D(1, 1, qc);
}