Problem: You are given a special undirected graph. It consists of 2n vertices numbered from 1 to 2n. The following properties hold for the graph:

  * there are exactly 3n-2 edges in the graph: n edges connect vertices having odd numbers with vertices having even numbers, n - 1 edges connect vertices having odd numbers with each other, and n - 1 edges connect vertices having even numbers with each other; 
  * for each edge (u, v) between a pair of vertices with odd numbers, there exists an edge (u + 1, v + 1), and vice versa; 
  * for each odd number u ∈ [1, 2n - 1], there exists an edge (u, u + 1); 
  * the graph is connected; moreover, if we delete all vertices with even numbers from it, and all edges incident to them, the graph will become a tree (the same applies to deleting odd vertices).



So, the graph can be represented as two trees having the same structure, and n edges connecting each vertex of the first tree to the corresponding vertex of the second tree.

Edges of the graph are weighted. The length of some simple path in the graph is the sum of weights of traversed edges.

You are given q queries to this graph; in each query, you are asked to compute the length of the shortest path between some pair of vertices in this graph. Can you answer all of the queries?

Input

The first line of the input contains one integer n (2 ≤ n ≤ 3 ⋅ 10^5).

The second line contains n integers w_{1, 2}, w_{3,4}, ..., w_{2n - 1, 2n} (1 ≤ w_{i, i + 1} ≤ 10^{12}). These integers describe the weights of the edges connecting odd vertices with even ones.

Then n-1 lines follow. i-th line contains four integers x_i, y_i, w_{i, 1} and w_{i, 2} (1 ≤ x_i, y_i ≤ n, x_i ≠ y_i, 1 ≤ w_{i, j} ≤ 10^{12}); it describes two edges: one connecting 2x_i - 1 with 2y_i - 1 and having weight w_{i, 1}; another connecting 2x_i with 2y_i and having weight w_{i, 2}.

The next line contains one integer q (1 ≤ q ≤ 6 ⋅ 10^5) — the number of queries.

Then q lines follow, i-th line contains two integers u_i and v_i (1 ≤ u_i, v_i ≤ 2n, u_i ≠ v_i), describing a query "compute the length of the shortest path between vertices u_i and v_i".

Output

Print q integers, i-th integer should be equal to the answer to the i-th query.

Example

Input


5
3 6 15 4 8
1 2 5 4
2 3 5 7
1 4 1 5
1 5 2 1
3
1 2
5 6
1 10


Output


3
15
4

Note

The graph in the first test looks like that:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e18;
const int mod = 1000000007;
const int N = 2 * 3 * 100000 + 10;
int n, sz[N], curSz, vis[N], vs = 1, k;
long long cost[N], ans[N];
pair<int, int> cq[N];
bool block[N];
vector<int> clr, qu[N], all, g[N];
vector<pair<int, long long> > adj[N];
void pre(int u, int p) {
  sz[u] = 1;
  for (auto f : qu[u]) all.push_back(f);
  for (auto v : g[u]) {
    if (v == p || block[v]) continue;
    pre(v, u);
    sz[u] += sz[v];
  }
}
struct state {
  int src;
  long long cost;
  state() {}
  state(int _src, long long _cost) { src = _src, cost = _cost; }
  bool operator<(const state &rhs) const { return cost > rhs.cost; }
};
priority_queue<state> q;
void dijsktra(int u) {
  q.push(state(u, 0));
  cost[u] = 0;
  while (q.size()) {
    state ss = q.top();
    q.pop();
    if (vis[ss.src] == vs) continue;
    clr.push_back(ss.src);
    for (auto v : adj[ss.src]) {
      if (block[v.first]) continue;
      long long newCost = v.second + ss.cost;
      if (newCost < cost[v.first]) {
        cost[v.first] = newCost;
        q.push(state(v.first, newCost));
      }
    }
  }
}
void clear() {
  vs++;
  while (clr.size()) {
    cost[clr.back()] = 1e18;
    clr.pop_back();
  }
}
int findCen(int u, int p) {
  int cen = -1, mx = 0;
  for (auto v : g[u]) {
    if (v == p || block[v]) continue;
    cen = max(cen, findCen(v, u));
    mx = max(sz[v], mx);
  }
  mx = max(mx, curSz - sz[u]);
  if (2 * mx <= curSz) cen = u;
  return cen;
}
void solve(int u) {
  all.clear();
  pre(u, -1);
  curSz = sz[u];
  int curCen = findCen(u, -1);
  for (int it = 0; it <= 1; ++it) {
    dijsktra(curCen - it);
    for (auto v : all)
      ans[v] = min(ans[v], cost[cq[v].first] + cost[cq[v].second]);
    clear();
  }
  block[curCen] = block[curCen - 1] = 1;
  for (auto v : g[curCen]) {
    if (block[v]) continue;
    solve(v);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= 2 * n; ++i) cost[i] = 1e18;
  for (int i = 1; i <= n; ++i) {
    long long w;
    scanf("%lld", &w);
    adj[2 * i].push_back(make_pair(2 * i - 1, w));
    adj[2 * i - 1].push_back(make_pair(2 * i, w));
  }
  for (int first, second, i = 0; i < n - 1; ++i) {
    long long w1, w2;
    scanf("%d%d%lld%lld", &first, &second, &w1, &w2);
    g[2 * first].push_back(2 * second);
    g[2 * second].push_back(2 * first);
    adj[2 * first - 1].push_back(make_pair(2 * second - 1, w1));
    adj[2 * second - 1].push_back(make_pair(2 * first - 1, w1));
    adj[2 * first].push_back(make_pair(2 * second, w2));
    adj[2 * second].push_back(make_pair(2 * first, w2));
  }
  cin >> k;
  for (int i = 0; i < k; ++i) {
    scanf("%d%d", &cq[i].first, &cq[i].second);
    ans[i] = oo;
    qu[cq[i].first + (cq[i].first % 2)].push_back(i);
  }
  solve(2);
  for (int i = 0; i < k; ++i) printf("%lld\n", ans[i]);
  return 0;
}