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 db = double;
using ll = long long;
using uint = unsigned int;
using pii = pair<long long, long long>;
template <class T>
void cmax(T& x, const T& y) {
  if (x < y) x = y;
}
template <class T>
void cmin(T& x, const T& y) {
  if (x > y) x = y;
}
template <class T>
void sort(vector<T>& v) {
  sort(v.begin(), v.end());
}
template <class T>
void unique(vector<T>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
template <class T>
void reverse(vector<T>& v) {
  reverse(v.begin(), v.end());
}
const long long SZ = 0x191981;
struct FILEIN {
  ~FILEIN() {}
  char qwq[SZ], *S = qwq, *T = qwq, ch;
  char GETC() {
    return (S == T) && (T = (S = qwq) + fread(qwq, 1, SZ, stdin), S == T)
               ? EOF
               : *S++;
  }
  FILEIN& operator>>(char& c) {
    while (isspace(c = GETC()))
      ;
    return *this;
  }
  FILEIN& operator>>(string& s) {
    while (isspace(ch = GETC()))
      ;
    s = ch;
    while (!isspace(ch = GETC())) s += ch;
    return *this;
  }
  template <class T>
  void read(T& x) {
    bool sign = 1;
    while ((ch = GETC()) < 0x30)
      if (ch == 0x2d) sign = 0;
    x = (ch ^ 0x30);
    while ((ch = GETC()) > 0x2f) x = x * 0xa + (ch ^ 0x30);
    x = sign ? x : -x;
  }
  FILEIN& operator>>(long long& x) { return read(x), *this; }
  FILEIN& operator>>(signed& x) { return read(x), *this; }
  FILEIN& operator>>(unsigned& x) { return read(x), *this; }
} in;
struct FILEOUT {
  const static long long LIMIT = 0x114514;
  char quq[SZ], ST[0x114];
  signed sz, O;
  ~FILEOUT() { flush(); }
  void flush() {
    fwrite(quq, 1, O, stdout);
    fflush(stdout);
    O = 0;
  }
  FILEOUT& operator<<(char c) { return quq[O++] = c, *this; }
  FILEOUT& operator<<(string str) {
    if (O > LIMIT) flush();
    for (char c : str) quq[O++] = c;
    return *this;
  }
  template <class T>
  void write(T x) {
    if (O > LIMIT) flush();
    if (x < 0) {
      quq[O++] = 0x2d;
      x = -x;
    }
    do {
      ST[++sz] = x % 0xa ^ 0x30;
      x /= 0xa;
    } while (x);
    while (sz) quq[O++] = ST[sz--];
    return;
  }
  FILEOUT& operator<<(long long x) { return write(x), *this; }
  FILEOUT& operator<<(signed x) { return write(x), *this; }
  FILEOUT& operator<<(unsigned x) { return write(x), *this; }
} out;
long long n, m, q;
const long long maxn = 2e5 + 52;
long long bg[maxn << 1], ed[maxn << 1];
long long isq[maxn], qu[maxn], qv[maxn];
struct edge {
  long long u, v, w;
} e[maxn << 1];
struct node {
  long long x, y;
  bool operator<(const node& other) const {
    return x == other.x ? y < other.y : x < other.x;
  }
};
map<node, long long> mp;
struct basis {
  long long p[32];
  void ins(long long x) {
    for (long long i = 30; ~i; i--)
      if (x & (1 << i)) {
        if (!p[i]) p[i] = x;
        x ^= p[i];
      }
  }
  long long qry(long long x) {
    for (long long i = 30; ~i; i--) cmin(x, x ^ p[i]);
    return x;
  }
} bs;
long long fa[maxn], dis[maxn], d[maxn];
long long find(long long x) { return x == fa[x] ? x : find(fa[x]); }
long long getdis(long long x) {
  return x == fa[x] ? 0 : dis[x] ^ getdis(fa[x]);
}
vector<long long> v[maxn << 2];
void upd(long long a, long long b, long long l, long long r, long long rt,
         long long x) {
  if (a <= l && r <= b) {
    v[rt].emplace_back(x);
    return;
  }
  long long mid = l + r >> 1;
  if (a <= mid) upd(a, b, l, mid, rt << 1, x);
  if (b > mid) upd(a, b, mid + 1, r, rt << 1 | 1, x);
}
long long top = 0;
struct Node {
  long long x, y;
} st[maxn << 4];
void solve(long long l, long long r, long long rt, basis g) {
  const long long T = top;
  for (long long x : v[rt]) {
    long long u = e[x].u, v = e[x].v, w = e[x].w;
    long long fx = find(u), fy = find(v);
    w ^= getdis(u) ^ getdis(v);
    if (fx == fy)
      g.ins(w);
    else {
      if (d[fx] > d[fy]) swap(fx, fy);
      fa[fx] = fy, dis[fx] = w;
      st[++top] = {fx, d[fx] == d[fy]};
      d[fy] += d[fx] == d[fy];
    }
  }
  if (l == r) {
    if (isq[l]) {
      long long t = getdis(qu[l]) ^ getdis(qv[l]);
      out << g.qry(t) << '\n';
    }
  } else {
    long long mid = l + r >> 1;
    solve(l, mid, rt << 1, g);
    solve(mid + 1, r, rt << 1 | 1, g);
  }
  while (top > T) {
    long long x = st[top].x, y = st[top].y;
    d[fa[x]] -= y, fa[x] = x, dis[x] = 0;
    top--;
  }
}
signed main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  in >> n >> m;
  for (register long long i = (1); i <= (m); ++i) {
    long long u, v, w;
    in >> u >> v >> w;
    e[i] = {u, v, w};
  }
  in >> q;
  for (register long long i = (1); i <= (m); ++i) {
    bg[i] = 1, ed[i] = q;
    mp[{e[i].u, e[i].v}] = i;
  }
  for (register long long i = (1); i <= (q); ++i) {
    long long op, x, y, z;
    in >> op;
    if (op == 1) {
      in >> x >> y >> z;
      e[++m] = {x, y, z};
      bg[m] = i, ed[m] = q, mp[{x, y}] = m;
    }
    if (op == 2) {
      in >> x >> y, ed[mp[{x, y}]] = i - 1;
    }
    if (op == 3) {
      isq[i] = 1, in >> x >> y;
      qu[i] = x, qv[i] = y;
    }
  }
  for (long long i = 1; i <= m; i++)
    if (bg[i] <= ed[i]) upd(bg[i], ed[i], 1, q, 1, i);
  for (long long i = 1; i <= n; i++) fa[i] = i;
  solve(1, q, 1, bs);
  return 0;
}