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 int NMAX = 300010;
struct Edge {
  int to;
  long long c[2];
};
struct Tranz {
  long long c[2][2];
  Tranz() { fill(c[0], c[2], 1e18); }
  void build(long long* cost, long long ch1, long long ch2) {
    c[0][0] = min(cost[0], ch1 + ch2 + cost[1]);
    c[1][1] = min(cost[1], ch1 + ch2 + cost[0]);
    c[1][0] = min(cost[1] + ch2, ch1 + cost[0]);
    c[0][1] = min(cost[0] + ch2, ch1 + cost[1]);
  }
  friend Tranz compute(const Tranz& a, const Tranz& b) {
    Tranz ans;
    for (int i = 0; i <= 1; i++)
      for (int j = 0; j <= 1; j++)
        for (int k = 0; k <= 1; k++)
          ans.c[i][k] = min(ans.c[i][k], a.c[i][j] + b.c[j][k]);
    return ans;
  }
};
vector<Edge> adia[NMAX];
long long transp[NMAX];
long long trinit[NMAX];
int h[NMAX];
Tranz cost[20][NMAX];
int stramos[20][NMAX];
int n;
long long cost_djk(int fr, int p1, int to, int p2) {
  vector<int> dst[2] = {vector<int>(n + 1, 1e9), vector<int>(n + 1, 1e9)};
  priority_queue<pair<int, pair<int, int>>> q;
  dst[p1][fr] = 0;
  q.push({0, {p1, fr}});
  int d, nod, p;
  while (!q.empty()) {
    d = -q.top().first;
    tie(p, nod) = q.top().second;
    q.pop();
    if (d != dst[p][nod]) continue;
    for (auto i : adia[nod]) {
      if (dst[p][i.to] > d + i.c[p]) {
        dst[p][i.to] = d + i.c[p];
        q.push({-dst[p][i.to], {p, i.to}});
      }
    }
    if (dst[1 - p][nod] > d + trinit[nod]) {
      dst[1 - p][nod] = d + trinit[nod];
      q.push({-dst[1 - p][nod], {1 - p, nod}});
    }
  }
  return dst[p2][to];
}
void dfsdown(int nod, int tata) {
  for (auto i : adia[nod]) {
    if (i.to != tata) {
      dfsdown(i.to, nod);
      transp[nod] = min(transp[nod], transp[i.to] + i.c[0] + i.c[1]);
    }
  }
}
void dfsup(int nod, int tata) {
  h[nod] = 1 + h[tata];
  stramos[0][nod] = tata;
  for (int i = 1; i < 20; i++) {
    stramos[i][nod] = stramos[i - 1][stramos[i - 1][nod]];
    cost[i][nod] = compute(cost[i - 1][nod], cost[i - 1][stramos[i - 1][nod]]);
  }
  for (auto i : adia[nod]) {
    if (i.to != tata) {
      transp[i.to] = min(transp[i.to], transp[nod] + i.c[0] + i.c[1]);
      cost[0][i.to].build(i.c, transp[i.to], transp[nod]);
      dfsup(i.to, nod);
    }
  }
}
long long lca(int a, int p1, int b, int p2) {
  if (h[a] < h[b]) swap(a, b), swap(p1, p2);
  Tranz x, y;
  x.c[0][0] = x.c[1][1] = y.c[0][0] = y.c[1][1] = 0;
  x.c[0][1] = x.c[1][0] = transp[a];
  y.c[0][1] = y.c[1][0] = transp[b];
  for (int i = 19; i >= 0; i--)
    if (h[a] - (1 << i) >= h[b]) x = compute(x, cost[i][a]), a = stramos[i][a];
  if (a == b) return x.c[p1][p2];
  for (int i = 19; i >= 0; i--)
    if (stramos[i][a] != stramos[i][b])
      x = compute(x, cost[i][a]), y = compute(y, cost[i][b]), a = stramos[i][a],
      b = stramos[i][b];
  x = compute(x, cost[0][a]);
  y = compute(y, cost[0][b]);
  swap(y.c[1][0], y.c[0][1]);
  x = compute(x, y);
  return x.c[p1][p2];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  long long c1, c2;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> transp[i];
    trinit[i] = transp[i];
  }
  for (int i = 1; i < n; i++) {
    cin >> a >> b >> c1 >> c2;
    adia[a].push_back({b, {c1, c2}});
    adia[b].push_back({a, {c1, c2}});
  }
  dfsdown(1, 0);
  dfsup(1, 0);
  int q;
  cin >> q;
  while (q--) {
    cin >> a >> b;
    int p1 = !(a & 1), p2 = !(b & 1);
    a = (a + 1) / 2, b = (b + 1) / 2;
    cout << lca(a, p1, b, p2) << '\n';
  }
  return 0;
}