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;
const int N = 200005;
const int E = 500005;
struct edge {
  int x, y, w;
} e[E];
struct Q {
  int x, y, opt, w;
} q[N];
struct linebase {
  int r[32];
  void ins(int v) {
    for (int i = 30; i >= 0; i--) {
      if ((v >> i) & 1) {
        if (!r[i]) {
          return (void)(r[i] = v);
        } else
          v ^= r[i];
      }
    }
  }
  int ask(int v) {
    for (int i = 30; i >= 0; i--) {
      if ((r[i] ^ v) < v) {
        v ^= r[i];
      }
    }
    return v;
  }
} g[N << 2];
vector<int> vec[N << 2];
stack<edge> stk;
map<pair<int, int>, int> mp;
int fa[N], h[N], s[N], ans[N], las[N], pr[N];
int read() {
  int x = 0, v = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; v = (ch == '-') ? (-1) : (v), ch = getchar())
    ;
  for (; ch <= '9' && ch >= '0'; x = x * 10 + ch - '0', ch = getchar())
    ;
  return x * v;
}
int find(int x) { return (!fa[x]) ? x : (find(fa[x])); }
int query(int x) { return (!fa[x]) ? 0 : (query(fa[x]) ^ s[x]); }
void solve(int now, int tl, int tr) {
  if (tl > tr) return;
  int rec = stk.size();
  for (int i = 0; i < vec[now].size(); ++i) {
    edge tmp = e[vec[now][i]];
    int x = tmp.x, y = tmp.y;
    int fx = find(x), fy = find(y);
    if (h[fx] > h[fy]) {
      swap(fx, fy);
      swap(x, y);
    }
    if (fx == fy) {
      g[now].ins(query(x) ^ query(y) ^ tmp.w);
    } else {
      if (h[fx] == h[fy]) {
        h[fy]++;
        stk.push((edge){fx, fy, -tmp.w});
      } else
        stk.push((edge){fx, fy, tmp.w});
      fa[fx] = fy;
      s[fx] = tmp.w ^ query(y) ^ query(x);
    }
  }
  if (tl == tr) {
    ans[tl] = g[now].ask(query(q[pr[tl]].x) ^ query(q[pr[tl]].y));
    for (; stk.size() > rec;) {
      edge tmp = stk.top();
      stk.pop();
      fa[tmp.x] = 0;
      h[tmp.y] -= (tmp.w <= 0);
      s[tmp.x] = 0;
    }
    return;
  }
  int mid = (tl + tr) >> 1;
  g[now << 1] = g[now];
  solve(now << 1, tl, mid);
  g[now << 1 | 1] = g[now];
  solve(now << 1 | 1, mid + 1, tr);
  for (; stk.size() > rec;) {
    edge tmp = stk.top();
    stk.pop();
    fa[tmp.x] = 0;
    h[tmp.y] -= (tmp.w <= 0);
    s[tmp.x] = 0;
  }
}
void modify(int now, int tl, int tr, int l, int r, int id) {
  if (r < l) {
    return;
  }
  if (tl >= l && tr <= r) {
    vec[now].push_back(id);
    return;
  }
  int mid = (tl + tr) >> 1;
  modify(now << 1, tl, mid, l, min(r, mid), id);
  modify(now << 1 | 1, mid + 1, tr, max(mid + 1, l), r, id);
}
int main(void) {
  int n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read(), w = read();
    if (x > y) {
      swap(x, y);
    }
    e[i].x = x, e[i].y = y, e[i].w = w;
    mp[pair<int, int>(x, y)] = i;
    las[i] = 1;
  }
  int cnt = 0, T = read();
  for (int i = 1; i <= T; i++) {
    q[i].opt = read(), q[i].x = read(), q[i].y = read();
    if (q[i].x > q[i].y) {
      swap(q[i].x, q[i].y);
    }
    if (q[i].opt == 1) {
      q[i].w = read();
      if (!mp[pair<int, int>(q[i].x, q[i].y)]) {
        mp[pair<int, int>(q[i].x, q[i].y)] = ++m;
        e[m] = (edge){q[i].x, q[i].y, q[i].w};
      }
    }
    cnt += (q[i].opt == 3);
  }
  int wjp = 0;
  for (int i = 1; i <= T; i++) {
    int x = q[i].x, y = q[i].y, opt = q[i].opt;
    int id = mp[pair<int, int>(x, y)];
    if (opt == 1) {
      las[id] = wjp + 1;
    } else if (opt == 2) {
      modify(1, 1, cnt, las[id], wjp, id);
      las[id] = 0;
    } else
      pr[++wjp] = i;
  }
  for (int i = 1; i <= m; i++) {
    if (las[i]) {
      modify(1, 1, cnt, las[i], cnt, i);
    }
  }
  solve(1, 1, cnt);
  for (int i = 1; i <= cnt; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}