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;
long long n, m, cw, bb, zh[300100], first[300100], size[300100], ans[600100],
    dis[300100][2][2], vis[300100], hk[300100];
bool gg[300100];
struct Bn {
  long long to, next, quan[2];
} bn[300100 << 1];
struct Que {
  long long ta, tb, id;
};
vector<Que> que[300100][2];
vector<long long> use;
inline void Min(long long &u, long long v) {
  if (v < u) u = v;
}
inline void add(long long u, long long v, long long p, long long q) {
  bb++;
  bn[bb].to = v;
  bn[bb].next = first[u];
  bn[bb].quan[0] = p;
  bn[bb].quan[1] = q;
  first[u] = bb;
}
void gs(long long now, long long last) {
  long long p, q;
  size[now] = 1;
  for (p = first[now]; p != -1; p = bn[p].next) {
    q = bn[p].to;
    if (q == last || gg[q]) continue;
    gs(q, now);
    size[now] += size[q];
  }
}
long long gr(long long now, long long last, long long tot) {
  long long p, q;
  for (p = first[now]; p != -1; p = bn[p].next) {
    q = bn[p].to;
    if (q == last || gg[q]) continue;
    if (size[q] * 2 >= tot) return gr(q, now, tot);
  }
  return now;
}
long long get(long long now, long long last) {
  long long p, q, res = zh[now];
  for (p = first[now]; p != -1; p = bn[p].next) {
    q = bn[p].to;
    if (q == last || gg[q]) continue;
    res = min(res, get(q, now) + bn[p].quan[0] + bn[p].quan[1]);
  }
  return hk[now] = res;
}
void dfs(long long now, long long last) {
  long long p, q, i, j, k;
  vis[now] = cw;
  use.push_back(now);
  for (p = first[now]; p != -1; p = bn[p].next) {
    q = bn[p].to;
    if (q == last || gg[q]) continue;
    memset(dis[q], 0x3f, sizeof(dis[q]));
    for (i = 0; i < 2; i++) {
      for (j = 0; j < 2; j++) {
        for (k = 0; k < 2; k++) {
          if (i == j)
            Min(dis[q][i][k],
                dis[now][j][k] +
                    min(bn[p].quan[i], zh[now] + hk[q] + bn[p].quan[i ^ 1]));
          else
            Min(dis[q][i][k], dis[now][j][k] + min(bn[p].quan[i] + hk[now],
                                                   bn[p].quan[j] + hk[q]));
        }
      }
    }
    dfs(q, now);
  }
}
void work(long long now) {
  vis[now] = ++cw;
  gg[now] = 1;
  dis[now][0][0] = dis[now][1][1] = 0;
  dis[now][0][1] = dis[now][1][0] = get(now, -1);
  use.clear();
  dfs(now, -1);
  long long i, j, k, p, q;
  for (i = 0; i < use.size(); i++) {
    long long t = use[i];
    for (j = 0; j < que[t][0].size(); j++) {
      Que tmp = que[t][0][j];
      if (vis[tmp.ta] != cw) continue;
      Min(ans[tmp.id], min(dis[t][0][0] + dis[tmp.ta][tmp.tb][0],
                           dis[t][0][1] + dis[tmp.ta][tmp.tb][1]));
    }
    for (j = 0; j < que[t][1].size(); j++) {
      Que tmp = que[t][1][j];
      if (vis[tmp.ta] != cw) continue;
      Min(ans[tmp.id], min(dis[t][1][0] + dis[tmp.ta][tmp.tb][0],
                           dis[t][1][1] + dis[tmp.ta][tmp.tb][1]));
    }
  }
  for (p = first[now]; p != -1; p = bn[p].next) {
    q = bn[p].to;
    if (gg[q]) continue;
    gs(q, now);
    work(gr(q, now, size[q]));
  }
}
int main() {
  memset(ans, 0x3f, sizeof(ans));
  memset(first, -1, sizeof(first));
  long long i, j, a, b, p, q;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%lld", &zh[i]);
  for (i = 1; i < n; i++) {
    scanf("%lld%lld%lld%lld", &a, &b, &p, &q);
    add(a, b, p, q);
    add(b, a, p, q);
  }
  cin >> m;
  for (i = 1; i <= m; i++) {
    scanf("%lld%lld", &p, &q);
    p++, q++;
    que[p >> 1][p & 1].push_back((Que){q >> 1, q & 1, i});
    que[q >> 1][q & 1].push_back((Que){p >> 1, p & 1, i});
  }
  gs(1, -1);
  work(gr(1, -1, size[1]));
  for (i = 1; i <= m; i++) printf("%lld\n", ans[i]);
}