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;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "URDL";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 998244353) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
long long w[300135];
vector<pair<int, pair<long long, long long>>> mp[300135];
int d[300135], p[300135][20];
long long pt[300135][20][2][2];
void dfs1(int x, int pa) {
  d[x] = d[pa] + 1;
  p[x][0] = pa;
  for (auto cp : mp[x])
    if (cp.first != pa) {
      dfs1(cp.first, x);
      long long w0 = cp.second.first, w1 = cp.second.second;
      mintt(w[x], w[cp.first] + w0 + w1);
    }
}
void dfs2(int x, int pa) {
  for (auto cp : mp[x])
    if (cp.first != pa) {
      long long w0 = cp.second.first, w1 = cp.second.second;
      mintt(w[cp.first], w[x] + w0 + w1);
      dfs2(cp.first, x);
    }
}
void dfs3(int x, int pa) {
  for (auto cp : mp[x])
    if (cp.first != pa) {
      dfs3(cp.first, x);
      long long w1 = cp.second.first, w2 = cp.second.second;
      pt[cp.first][0][0][0] = min(w1, w2 + w[x] + w[cp.first]);
      pt[cp.first][0][1][1] = min(w2, w1 + w[x] + w[cp.first]);
      pt[cp.first][0][0][1] = min(w1 + w[x], w2 + w[cp.first]);
      pt[cp.first][0][1][0] = min(w2 + w[x], w1 + w[cp.first]);
    }
}
void init() {
  for (int j = 1; j < 20; j++)
    for (int i = 1; i <= n; i++) {
      p[i][j] = p[p[i][j - 1]][j - 1];
      int z = p[i][j - 1];
      pt[i][j][0][0] = min(pt[i][j - 1][0][0] + pt[z][j - 1][0][0],
                           pt[i][j - 1][0][1] + pt[z][j - 1][1][0]);
      pt[i][j][0][1] = min(pt[i][j - 1][0][0] + pt[z][j - 1][0][1],
                           pt[i][j - 1][0][1] + pt[z][j - 1][1][1]);
      pt[i][j][1][0] = min(pt[i][j - 1][1][0] + pt[z][j - 1][0][0],
                           pt[i][j - 1][1][1] + pt[z][j - 1][1][0]);
      pt[i][j][1][1] = min(pt[i][j - 1][1][0] + pt[z][j - 1][0][1],
                           pt[i][j - 1][1][1] + pt[z][j - 1][1][1]);
    }
}
int lca(int a, int b) {
  if (d[a] > d[b]) swap(a, b);
  int f = d[b] - d[a];
  for (int i = 0; (1 << i) <= f; i++)
    if ((1 << i) & f) b = p[b][i];
  if (a != b) {
    for (int i = 19; i >= 0; i--)
      if (p[a][i] != p[b][i]) {
        a = p[a][i];
        b = p[b][i];
      }
    a = p[a][0];
  }
  return a;
}
long long dp[2], dpv[2];
long long cal(int x, int y) {
  int u = (x + 1) / 2, v = (y + 1) / 2;
  int fa = lca(u, v);
  long long tp0, tp1;
  if (x & 1) {
    dp[0] = 0;
    dp[1] = w[u];
  } else {
    dp[1] = 0;
    dp[0] = w[u];
  }
  for (int j = 19; j >= 0; j--) {
    if (d[p[u][j]] >= d[fa]) {
      tp0 = dp[0];
      tp1 = dp[1];
      dp[0] = min(tp0 + pt[u][j][0][0], tp1 + pt[u][j][1][0]);
      dp[1] = min(tp0 + pt[u][j][0][1], tp1 + pt[u][j][1][1]);
      u = p[u][j];
    }
  }
  for (int(z) = 0; (z) < (int)(2); (z)++) dpv[z] = dp[z];
  u = v;
  if (y & 1) {
    dp[0] = 0;
    dp[1] = w[u];
  } else {
    dp[1] = 0;
    dp[0] = w[u];
  }
  for (int j = 19; j >= 0; j--) {
    if (d[p[u][j]] >= d[fa]) {
      tp0 = dp[0];
      tp1 = dp[1];
      dp[0] = min(tp0 + pt[u][j][0][0], tp1 + pt[u][j][1][0]);
      dp[1] = min(tp0 + pt[u][j][0][1], tp1 + pt[u][j][1][1]);
      u = p[u][j];
    }
  }
  return min(dp[0] + dpv[0], dp[1] + dpv[1]);
}
void fmain(int tid) {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%lld", w + i);
  for (int(i) = 1; (i) <= (int)(n - 1); (i)++) {
    int x, y;
    long long p, q;
    scanf("%d%d%lld%lld", &x, &y, &p, &q);
    mp[x].push_back({y, {p, q}});
    mp[y].push_back({x, {p, q}});
  }
  dfs1(1, 0);
  dfs2(1, 0);
  dfs3(1, 0);
  init();
  scanf("%d", &m);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    int x, y;
    scanf("%d%d", &x, &y);
    printf("%lld\n", cal(x, y));
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}