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;
using LL = long long;
namespace _buff {
const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
  if (ib == ie) {
    ib = ibuf;
    ie = ibuf + fread(ibuf, 1, BUFF, stdin);
  }
  return ib == ie ? -1 : *ib++;
}
}  // namespace _buff
LL read() {
  using namespace _buff;
  LL ret = 0;
  bool pos = true;
  char c = getc();
  for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
    assert(~c);
  }
  if (c == '-') {
    pos = false;
    c = getc();
  }
  for (; c >= '0' && c <= '9'; c = getc()) {
    ret = (ret << 3) + (ret << 1) + (c ^ 48);
  }
  return pos ? ret : -ret;
}
const size_t N = 2e5 + 5;
const size_t L = 30;
using P = pair<int, int>;
stack<pair<int *, int> > change_stk;
void change(int &x, int y) {
  change_stk.emplace(&x, x);
  x = y;
}
void travel(int t) {
  while (change_stk.size() > t) {
    auto [foo, val] = change_stk.top();
    change_stk.pop();
    *foo = val;
  }
}
struct Basis {
  int b[L];
  Basis() { memset(b, 0, sizeof b); }
  void add(int x) {
    for (int i = (int)L - 1; i >= 0; --i) {
      if (x >> i & 1) {
        if (b[i]) {
          x ^= b[i];
        } else {
          change(b[i], x);
          return;
        }
      }
    }
    assert(!x);
  }
  int query(int x) {
    for (int i = (int)L - 1; i >= 0; --i) {
      x = min(x, x ^ b[i]);
    }
    return x;
  }
} bas;
int rt[N], sz[N], ds[N];
P find(int x) {
  int d = 0;
  for (; rt[x] != x; x = rt[x]) {
    d ^= ds[x];
  }
  return {x, d};
}
void merge(int x, int y, int val) {
  auto [tx, dx] = find(x);
  x = tx;
  auto [ty, dy] = find(y);
  y = ty;
  if (x == y) {
    bas.add(val ^ dx ^ dy);
    return;
  }
  if (sz[x] < sz[y]) swap(x, y);
  change(rt[y], x);
  change(sz[x], sz[x] + sz[y]);
  change(ds[y], val ^ dx ^ dy);
}
vector<P> ask[N];
vector<pair<P, int> > tree[N << 2];
void modify(int x, int tl, int tr, int l, int r, pair<P, int> val) {
  if (tl >= r || tr <= l) return;
  if (l <= tl && tr <= r) {
    tree[x].emplace_back(val);
    return;
  }
  int mid = (tl + tr) >> 1;
  modify(((x) << 1), tl, mid, l, r, val);
  modify(((x) << 1 | 1), mid, tr, l, r, val);
}
void solve(int x, int tl, int tr) {
  int tme = change_stk.size();
  for (auto [pr, val] : tree[x]) {
    auto [u, v] = pr;
    merge(u, v, val);
  }
  if (tl + 1 == tr) {
    for (auto [x, y] : ask[tl]) {
      printf("%d\n", bas.query(find(x).second ^ find(y).second));
    }
  } else {
    int mid = (tl + tr) >> 1;
    solve(((x) << 1), tl, mid);
    solve(((x) << 1 | 1), mid, tr);
  }
  travel(tme);
}
int main() {
  int n = read(), m = read();
  iota(rt, rt + n + 1, 0);
  fill(sz, sz + n + 1, 1);
  vector<pair<pair<P, int>, P> > vc;
  map<P, P> mp;
  int t = 0;
  for (int i = 0; i < m; ++i) {
    int x = read(), y = read(), v = read();
    mp[{x, y}] = {t, v};
  }
  int q = read();
  while (q--) {
    int typ = read();
    if (typ == 1) {
      ++t;
      int x = read(), y = read(), v = read();
      mp[{x, y}] = {t, v};
    } else if (typ == 2) {
      ++t;
      int x = read(), y = read();
      auto it = mp.find({x, y});
      assert(it != mp.end());
      vc.emplace_back(make_pair(make_pair(make_pair(x, y), it->second.second),
                                make_pair(it->second.first, t)));
      mp.erase(it);
    } else {
      int x = read(), y = read();
      ask[t].emplace_back(x, y);
    }
  }
  ++t;
  for (auto [e, lr] : vc) {
    auto [l, r] = lr;
    modify(1, 0, t, l, r, e);
  }
  for (auto [e, pr] : mp) {
    auto [s, v] = pr;
    modify(1, 0, t, s, t, make_pair(e, v));
  }
  solve(1, 0, t);
  return 0;
}