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;
vector<vector<int> > adj(300001);
int edgeEndXors[300001], depth[300001], ancestors[19][300001];
long long weights[300001][2], crossWeights[300001], d[300001],
    dp[19][300001][2][2], temp[2][2], a[2][2], b[2][2], c[2][2];
void PreProcess(int n) {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      Q;
  for (int i = 1; i <= n; ++i) {
    d[i] = crossWeights[i];
    Q.push(make_pair(d[i], i));
  }
  while (!Q.empty()) {
    long long di;
    int i;
    tie(di, i) = Q.top();
    Q.pop();
    if (di > d[i]) {
      continue;
    }
    for (int x : adj[i]) {
      int j = edgeEndXors[x] ^ i;
      long long dj = di + weights[x][0] + weights[x][1];
      if (dj < d[j]) {
        d[j] = dj;
        Q.push(make_pair(dj, j));
      }
    }
  }
}
void Compute(long long a[2][2], long long b[2][2], long long c[2][2]) {
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      long long &val = temp[i][j];
      val = LLONG_MAX;
      for (int k = 0; k < 2; ++k) {
        val = min(val, a[i][k] + b[k][j]);
      }
    }
  }
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      c[i][j] = temp[i][j];
    }
  }
}
void DFS(int i, int p) {
  depth[i] = 1 + depth[p];
  for (int k = 1; k < 19; ++k) {
    int j = ancestors[k - 1][i];
    ancestors[k][i] = ancestors[k - 1][j];
    Compute(dp[k - 1][i], dp[k - 1][j], dp[k][i]);
  }
  for (int x : adj[i]) {
    int j = edgeEndXors[x] ^ i;
    if (j == p) {
      continue;
    }
    ancestors[0][j] = i;
    dp[0][j][0][0] = min(weights[x][0], d[j] + weights[x][1] + d[i]);
    dp[0][j][0][1] = min(d[i] + weights[x][0], d[j] + weights[x][1]);
    dp[0][j][1][0] = min(d[i] + weights[x][1], d[j] + weights[x][0]);
    dp[0][j][1][1] = min(weights[x][1], d[j] + weights[x][0] + d[i]);
    DFS(j, i);
  }
}
int LCA(int i, int j) {
  if (depth[i] > depth[j]) {
    swap(i, j);
  }
  for (int k = 19 - 1, x = depth[j] - depth[i]; x; --k) {
    if ((1 << k) <= x) {
      j = ancestors[k][j];
      x -= (1 << k);
    }
  }
  if (i == j) {
    return i;
  }
  for (int k = 19 - 1; ancestors[0][i] != ancestors[0][j]; --k) {
    if (ancestors[k][i] != ancestors[k][j]) {
      i = ancestors[k][i], j = ancestors[k][j];
    }
  }
  return ancestors[0][i];
}
void ComputeTillKthAncestors(int i, int l, long long a[2][2]) {
  for (int x = 0; x < 2; ++x) {
    for (int y = 0; y < 2; ++y) {
      a[x][y] = 0;
    }
  }
  a[0][1] = a[1][0] = d[i];
  for (int k = 19 - 1; k > -1 && l > 0; --k) {
    if (l < (1 << k)) {
      continue;
    }
    Compute(a, dp[k][i], a);
    i = ancestors[k][i];
    l -= (1 << k);
  }
}
long long Query(int i, int j) {
  int pi = (i + 1) / 2, pj = (j + 1) / 2;
  int qi = (i + 1) % 2, qj = (j + 1) % 2;
  int pk = LCA(pi, pj);
  ComputeTillKthAncestors(pi, depth[pi] - depth[pk], a);
  ComputeTillKthAncestors(pj, depth[pj] - depth[pk], b);
  swap(b[0][1], b[1][0]);
  Compute(a, b, c);
  return c[qi][qj];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &crossWeights[i]);
  }
  for (int x = 1; x < n; ++x) {
    int i, j;
    scanf("%d%d%lld%lld", &i, &j, &weights[x][0], &weights[x][1]);
    edgeEndXors[x] = (i ^ j);
    adj[i].push_back(x);
    adj[j].push_back(x);
  }
  PreProcess(n);
  DFS(1, 0);
  int q;
  scanf("%d", &q);
  while (q--) {
    int i, j;
    scanf("%d%d", &i, &j);
    printf("%lld\n", Query(i, j));
  }
  return 0;
}