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 int getint() {
  int x = 0, p = 1;
  char c = getchar();
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
const int N = 4e5 + 10;
struct linearbasis {
  int b[31];
  linearbasis() { memset(b, 0, sizeof(b)); }
  inline void ins(int x) {
    for (int i = 30; i >= 0; i--) {
      if (!(x >> i & 1)) continue;
      if (b[i]) {
        x ^= b[i];
        continue;
      }
      for (int(j) = 0; (j) < (i); (j)++)
        if (x >> j & 1) x ^= b[j];
      for (int j = i + 1; j < 31; j++)
        if (b[j] >> i & 1) b[j] ^= x;
      b[i] = x;
      break;
    }
  }
  inline int qry(int x) {
    for (int i = 30; i >= 0; i--)
      if ((x ^ b[i]) < x) x ^= b[i];
    return x;
  }
} B[N << 1];
int n, m, q;
int par[N], val[N], res[N], sz[N];
int ex[N], ey[N], ez[N], q0[N], q1[N], q2[N], q3[N];
int L[N], R[N], cnt;
set<pair<pair<int, int>, int> > S;
vector<pair<int, int> > st;
vector<int> e[N << 1];
set<pair<pair<int, int>, int> >::iterator it;
inline int getval(int x) {
  if (par[x] == x) return 0;
  return getval(par[x]) ^ val[x];
}
int fF(int x) {
  if (par[x] == x) return x;
  return fF(par[x]);
}
inline bool fU(int x, int y, int z) {
  z ^= getval(x);
  z ^= getval(y);
  x = fF(x);
  y = fF(y);
  if (sz[x] > sz[y]) swap(x, y);
  st.emplace_back(x, y);
  if (x == y) return false;
  sz[y] += sz[x];
  par[x] = y;
  val[x] = z;
  return true;
}
inline void undo() {
  pair<int, int> u = st.back();
  st.pop_back();
  if (u.first == u.second) return;
  val[u.first] = val[u.second] = 0;
  par[u.first] = u.first;
  sz[u.second] -= sz[u.first];
}
inline void init(int x) {
  sz[x] = 1;
  val[x] = 0;
  par[x] = x;
}
void build(int l, int r, int x, int y, int id, int k) {
  if (l >= y || x >= r) return;
  if (x <= l && r <= y) {
    e[k].push_back(id);
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, x, y, id, 2 * k + 1);
  build(mid, r, x, y, id, 2 * k + 2);
}
void solve(int l, int r, int k) {
  for (int(i) = 0; (i) < (e[k].size()); (i)++)
    if (!fU(ex[e[k][i]], ey[e[k][i]], ez[e[k][i]])) {
      B[k].ins(getval(ex[e[k][i]]) ^ getval(ey[e[k][i]]) ^ ez[e[k][i]]);
    }
  if (r - l == 1) {
    if (q0[l] == 3) res[l] = B[k].qry(getval(q1[l]) ^ getval(q2[l]));
  } else {
    B[2 * k + 1] = B[2 * k + 2] = B[k];
    int mid = (l + r) >> 1;
    solve(l, mid, 2 * k + 1);
    solve(mid, r, 2 * k + 2);
  }
  for (int(i) = 0; (i) < (e[k].size()); (i)++) undo();
}
int main() {
  n = getint();
  m = getint();
  for (int(i) = 0; (i) < (m); (i)++) {
    ex[i] = getint() - 1, ey[i] = getint() - 1, ez[i] = getint(), L[i] = 0,
    R[i] = q;
    if (ex[i] > ey[i]) swap(ex[i], ey[i]);
    S.insert(make_pair(make_pair(ex[i], ey[i]), i));
  }
  cnt = m;
  q = getint();
  for (int(i) = 0; (i) < (m); (i)++) R[i] = q;
  for (int(qqq) = 0; (qqq) < (q); (qqq)++) {
    int op = getint(), x = getint() - 1, y = getint() - 1;
    if (x > y) swap(x, y);
    q0[qqq] = op;
    q1[qqq] = x, q2[qqq] = y;
    if (op == 1) {
      int z = getint();
      ex[cnt] = x, ey[cnt] = y, ez[cnt] = z;
      L[cnt] = qqq;
      R[cnt++] = q;
      S.insert(make_pair(make_pair(x, y), cnt - 1));
    } else if (op == 2) {
      it = S.lower_bound(make_pair(make_pair(x, y), -1000000000));
      R[it->second] = qqq;
      S.erase(it);
    }
  }
  for (int(i) = 0; (i) < (cnt); (i)++) build(0, q, L[i], R[i], i, 0);
  for (int(i) = 0; (i) < (n); (i)++) init(i);
  memset(res, -1, sizeof(res));
  solve(0, q, 0);
  for (int(i) = 0; (i) < (q); (i)++)
    if (res[i] != -1) printf("%d\n", res[i]);
  return 0;
}