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 N = 300005, G = 19, inf = 4e18;
long long n, q, v[N], dep[N], par[G][N], cost[G][N][2][2];
vector<pair<long long, pair<long long, long long> > > adj[N];
void downcalc(long long C, long long P) {
  for (auto &first : adj[C]) {
    long long T = first.first, A, B;
    tie(A, B) = first.second;
    if (T == P) continue;
    downcalc(T, C);
    v[C] = min(v[C], v[T] + A + B);
  }
}
void upcalc(long long C, long long P) {
  for (auto &first : adj[C]) {
    long long T = first.first, A, B;
    tie(A, B) = first.second;
    if (T == P) continue;
    par[0][T] = C;
    dep[T] = dep[C] + 1;
    v[T] = min(v[T], v[C] + A + B);
    cost[0][T][0][0] = min(v[C] + v[T] + B, A);
    cost[0][T][0][1] = min(A + v[C], B + v[T]);
    cost[0][T][1][0] = min(A + v[T], B + v[C]);
    cost[0][T][1][1] = min(v[C] + v[T] + A, B);
    upcalc(T, C);
  }
}
long long getlca(long long A, long long B) {
  if (dep[A] < dep[B]) swap(A, B);
  for (long long i = G; i--;) {
    if (dep[A] - dep[B] >= (1 << i)) A = par[i][A];
  }
  if (A == B) return A;
  for (long long i = G; i--;) {
    if (par[i][A] != par[i][B]) {
      A = par[i][A];
      B = par[i][B];
    }
  }
  return par[0][A];
}
pair<long long, long long> get(long long first, long long second, long long Z) {
  long long V[2];
  V[second] = 0;
  V[second ^ 1] = v[first];
  for (long long i = G; i--;) {
    if (dep[first] - dep[Z] >= (1 << i)) {
      long long W[2] = {inf, inf};
      for (long long k1 = 0; k1 < 2; k1++)
        for (long long k2 = 0; k2 < 2; k2++) {
          W[k2] = min(W[k2], V[k1] + cost[i][first][k1][k2]);
        }
      V[0] = W[0];
      V[1] = W[1];
      first = par[i][first];
    }
  }
  return {V[0], V[1]};
}
void solve() {
  long long AX, AY, BX, BY, C;
  scanf("%lld%lld", &AX, &BX);
  AY = (AX - 1) % 2;
  AX = (AX - AY + 1) / 2;
  BY = (BX - 1) % 2;
  BX = (BX - BY + 1) / 2;
  C = getlca(AX, BX);
  pair<long long, long long> AA = get(AX, AY, C), BB = get(BX, BY, C);
  printf("%lld\n", min(AA.first + BB.first, AA.second + BB.second));
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &v[i]);
  }
  for (long long i = 1; i < n; i++) {
    long long A, B, C, D;
    scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
    adj[A].push_back({B, {C, D}});
    adj[B].push_back({A, {C, D}});
  }
  downcalc(1, 0);
  upcalc(1, 0);
  for (long long i = 1; i < G; i++) {
    for (long long j = 1; j <= n; j++) {
      par[i][j] = par[i - 1][par[i - 1][j]];
      for (int k1 = 0; k1 < 2; k1++)
        for (int k2 = 0; k2 < 2; k2++) {
          long long T = inf;
          for (int k3 = 0; k3 < 2; k3++) {
            T = min(
                T, cost[i - 1][j][k1][k3] + cost[i - 1][par[i - 1][j]][k3][k2]);
          }
          cost[i][j][k1][k2] = T;
        }
    }
  }
  scanf("%lld", &q);
  while (q--) solve();
}