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 inf = 1e18;
long long cross[300010], dp[300010][2][2], ans[600010];
vector<int> v[300010];
vector<pair<long long, long long> > edges[300010];
int root, centru, where[300010], cnt[300010];
char vaz[300010];
struct str {
  int x, y, t1, t2, poz;
};
vector<str> Q;
void dfsdown(int nod, int tata) {
  for (int i = 0; i < v[nod].size(); i++)
    if (v[nod][i] != tata) {
      dfsdown(v[nod][i], nod);
      cross[nod] = min(cross[nod], cross[v[nod][i]] + edges[nod][i].first +
                                       edges[nod][i].second);
    }
}
void dfsup(int nod, int tata) {
  for (int i = 0; i < v[nod].size(); i++)
    if (v[nod][i] != tata) {
      cross[v[nod][i]] =
          min(cross[v[nod][i]],
              cross[nod] + edges[nod][i].first + edges[nod][i].second);
      dfsup(v[nod][i], nod);
    }
}
void dfs(int nod, int tata) {
  cnt[nod] = 1;
  for (int i = 0; i < v[nod].size(); i++)
    if (v[nod][i] != tata && vaz[v[nod][i]] == 0) {
      dfs(v[nod][i], nod);
      cnt[nod] += cnt[v[nod][i]];
    }
}
void dfs1(int nod, int tata) {
  int p = 0;
  for (int j = 0; j < 2; j++) dp[nod][0][j] = dp[nod][1][j] = inf;
  for (int i = 0; i < v[nod].size(); i++)
    if (v[nod][i] != tata && vaz[v[nod][i]] == 0) {
      dfs1(v[nod][i], nod);
      if (cnt[v[nod][i]] > cnt[root] / 2) p = 1;
    }
  if (nod != root && cnt[root] - cnt[nod] > cnt[root] / 2) p = 1;
  if (p == 0) centru = nod;
}
void dfs2(int nod, int tata) {
  for (int i = 0; i < v[nod].size(); i++)
    if (v[nod][i] != tata && vaz[v[nod][i]] == 0) {
      int vec = v[nod][i];
      for (int j = 0; j < 2; j++) {
        dp[vec][1][j] = min(dp[vec][1][j], dp[nod][1][j] + edges[nod][i].first);
        dp[vec][0][j] =
            min(dp[vec][0][j], dp[nod][0][j] + edges[nod][i].second);
        dp[vec][1][j] = min(dp[vec][1][j],
                            dp[nod][0][j] + edges[nod][i].second + cross[vec]);
        dp[vec][0][j] = min(dp[vec][0][j],
                            dp[nod][1][j] + edges[nod][i].first + cross[vec]);
      }
      if (where[nod] == 0)
        where[vec] = i + 1;
      else
        where[vec] = where[nod];
      dfs2(vec, nod);
    }
}
void solve(int nod, vector<str> &qry) {
  root = nod;
  dfs(nod, 0);
  dfs1(nod, 0);
  dp[centru][0][0] = dp[centru][1][1] = 0;
  dp[centru][0][1] = dp[centru][1][0] = cross[centru];
  where[centru] = 0;
  dfs2(centru, 0);
  vector<str> aux[v[centru].size()];
  for (int i = 0; i < qry.size(); i++) {
    int x = qry[i].x, y = qry[i].y;
    if (where[x] != 0 && where[x] == where[y])
      aux[where[x] - 1].push_back(qry[i]);
    else {
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          ans[qry[i].poz] =
              min(ans[qry[i].poz], dp[x][qry[i].t1][j] + dp[y][qry[i].t2][k] +
                                       (j != k) * cross[centru]);
    }
  }
  vaz[centru] = 1;
  int aux1 = centru;
  for (int i = 0; i < v[aux1].size(); i++)
    if (vaz[v[aux1][i]] == 0) solve(v[aux1][i], aux[i]);
}
int main() {
  int n, x, y, q;
  long long c1, c2;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &cross[i]);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%I64d%I64d", &x, &y, &c1, &c2);
    v[x].push_back(y);
    v[y].push_back(x);
    edges[x].push_back({c1, c2});
    edges[y].push_back({c1, c2});
  }
  dfsdown(1, 0);
  dfsup(1, 0);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &x, &y);
    Q.push_back({(x + 1) / 2, (y + 1) / 2, x % 2, y % 2, i});
    ans[i] = inf;
  }
  solve(1, Q);
  for (int i = 1; i <= q; i++) printf("%I64d\n", ans[i]);
  return 0;
}