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;
typedef struct node {
  int leftEnd;
  int rightEnd;
  vector<int> edgeNoList;
  node* leftChild;
  node* rightChild;
} node;
node* BuildSegmentTree(int leftEnd, int rightEnd) {
  node* temp = new node;
  temp->leftEnd = leftEnd;
  temp->rightEnd = rightEnd;
  temp->edgeNoList.clear();
  if (leftEnd != rightEnd) {
    int mid = (leftEnd + rightEnd) / 2;
    temp->leftChild = BuildSegmentTree(leftEnd, mid);
    temp->rightChild = BuildSegmentTree(mid + 1, rightEnd);
  } else
    temp->leftChild = temp->rightChild = NULL;
  return temp;
}
void Update(node* currentNode, int l, int r, int edgeNo) {
  if (r < l || r < currentNode->leftEnd || currentNode->rightEnd < l)
    return;
  else {
    l = max(l, currentNode->leftEnd);
    r = min(r, currentNode->rightEnd);
    if (l == currentNode->leftEnd && r == currentNode->rightEnd) {
      currentNode->edgeNoList.push_back(edgeNo);
    } else {
      Update(currentNode->leftChild, l, r, edgeNo);
      Update(currentNode->rightChild, l, r, edgeNo);
    }
  }
}
int edgeU[2 * 200001], edgeV[2 * 200001], edgeW[2 * 200001], edgeS[2 * 200001],
    edgeF[2 * 200001], qU[200001], qV[200001], parent[200001],
    groupSize[200001], d[200001], bases[29 + 1], ans[200001], edgeNos;
map<pair<int, int>, int> S;
int Reduction(int x) {
  for (int k = 29; k > -1; --k) {
    if ((x & (1 << k)) > 0) x ^= bases[k];
  }
  return x;
}
void InsertBase(int x, stack<pair<int, int> >& rollbackBases) {
  x = Reduction(x);
  if (x == 0) return;
  int k;
  for (k = 29; k > -1 && (x & (1 << k)) == 0; --k)
    ;
  rollbackBases.push(make_pair(k, bases[k]));
  bases[k] = x;
}
int Find(int i) {
  while (parent[i] != i) i = parent[i];
  return i;
}
int Dis(int i) {
  int ans = 0;
  while (parent[i] != i) {
    ans ^= d[i];
    i = parent[i];
  }
  return ans;
}
void PushRollBackDSU(int i, stack<tuple<int, int, int, int> >& rollbackDSU) {
  rollbackDSU.push(make_tuple(i, parent[i], groupSize[i], d[i]));
}
void Union(int i, int j, int w, stack<tuple<int, int, int, int> >& rollbackDSU,
           stack<pair<int, int> >& rollbackBases) {
  w ^= (Dis(i) ^ Dis(j));
  i = Find(i), j = Find(j);
  if (i == j) {
    InsertBase(w, rollbackBases);
    return;
  }
  if (groupSize[i] < groupSize[j]) swap(i, j);
  PushRollBackDSU(i, rollbackDSU);
  PushRollBackDSU(j, rollbackDSU);
  parent[j] = i;
  groupSize[i] += groupSize[j];
  d[j] = w;
}
void ApplyRollBacks(stack<tuple<int, int, int, int> >& rollbackDSU,
                    stack<pair<int, int> >& rollbackBases) {
  while (!rollbackDSU.empty()) {
    int i, pi, gi, di;
    tie(i, pi, gi, di) = rollbackDSU.top();
    rollbackDSU.pop();
    parent[i] = pi;
    groupSize[i] = gi;
    d[i] = di;
  }
  while (!rollbackBases.empty()) {
    int k, bk;
    tie(k, bk) = rollbackBases.top();
    rollbackBases.pop();
    bases[k] = bk;
  }
}
void Solve(node* currentNode) {
  stack<tuple<int, int, int, int> > rollbackDSU;
  stack<pair<int, int> > rollbackBases;
  for (auto edgeNo : currentNode->edgeNoList)
    Union(edgeU[edgeNo], edgeV[edgeNo], edgeW[edgeNo], rollbackDSU,
          rollbackBases);
  if (currentNode->leftEnd != currentNode->rightEnd) {
    Solve(currentNode->leftChild);
    Solve(currentNode->rightChild);
  } else {
    int i = currentNode->leftEnd;
    if (qU[i] != 0) {
      ans[i] = Reduction(Dis(qU[i]) ^ Dis(qV[i]));
    }
  }
  ApplyRollBacks(rollbackDSU, rollbackBases);
}
int GetEdgeNo() {
  int i, j;
  scanf("%d%d", &i, &j);
  pair<int, int> p = make_pair(i, j);
  if (S.find(p) != S.end())
    return S[p];
  else {
    S[p] = ++edgeNos;
    edgeU[edgeNos] = i;
    edgeV[edgeNos] = j;
    return edgeNos;
  }
}
void AddEdge(int t) {
  int edgeNo = GetEdgeNo();
  scanf("%d", &edgeW[edgeNo]);
  edgeS[edgeNo] = t;
}
void RemoveEdge(int t) {
  int edgeNo = GetEdgeNo();
  edgeF[edgeNo] = t;
  S.erase(make_pair(edgeU[edgeNo], edgeV[edgeNo]));
}
int main() {
  int n, m, q;
  scanf("%d%d", &n, &m);
  while (m--) AddEdge(1);
  scanf("%d", &q);
  for (int x = 1; x <= q; ++x) {
    int t;
    scanf("%d", &t);
    if (t == 1)
      AddEdge(x);
    else if (t == 2)
      RemoveEdge(x);
    else
      scanf("%d%d", &qU[x], &qV[x]);
  }
  node* root = BuildSegmentTree(1, q);
  for (int x = 1; x <= edgeNos; ++x) {
    if (edgeF[x] == 0) edgeF[x] = q;
    Update(root, edgeS[x], edgeF[x], x);
  }
  for (int i = 1; i <= n; ++i) parent[i] = i, groupSize[i] = 1;
  Solve(root);
  for (int i = 1; i <= q; ++i) {
    if (qU[i] != 0) printf("%d\n", ans[i]);
  }
  return 0;
}