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;
struct node {
  int nxt, to;
  long long v1, v2;
} o[300010 << 1];
int n, q, F[300010][20], vis[300010], deep[300010], head[300010], I,
    fz[4] = {0, 2, 1, 3};
long long dp[300010], g[20][300010][4], X[4], Y[4];
vector<int> v[300010];
void add(int u, int v, long long w1, long long w2) {
  o[++I] = (node){head[u], v, w1, w2};
  head[u] = I;
}
void dfs1(int now, int fa) {
  F[now][0] = fa, deep[now] = deep[fa] + 1;
  for (int i = 1; i <= 19; i++) F[now][i] = F[F[now][i - 1]][i - 1];
  for (int i = head[now]; i; i = o[i].nxt) {
    int t = o[i].to;
    if (t ^ fa) dfs1(t, now), dp[now] = min(dp[now], dp[t] + o[i].v1 + o[i].v2);
  }
}
void dfs2(int now, int fa) {
  for (int i = head[now]; i; i = o[i].nxt) {
    int t = o[i].to;
    if (t ^ fa) dp[t] = min(dp[t], dp[now] + o[i].v1 + o[i].v2), dfs2(t, now);
  }
}
void dfs3(int now, int fa) {
  for (int i = head[now]; i; i = o[i].nxt) {
    int t = o[i].to;
    if (t == fa) continue;
    g[0][t][0] = min(o[i].v1, dp[t] + dp[now] + o[i].v2);
    g[0][t][1] = min(dp[t] + o[i].v2, dp[now] + o[i].v1);
    g[0][t][2] = min(dp[now] + o[i].v2, dp[t] + o[i].v1);
    g[0][t][3] = min(o[i].v2, dp[t] + dp[now] + o[i].v1);
    dfs3(t, now);
  }
}
void merge(long long* x, long long* y, long long* z) {
  if (!x[0] && !x[1] && !x[2] && !x[3]) {
    memcpy(z, y, 32);
    return;
  }
  g[0][0][0] = min(x[0] + y[0], x[1] + y[2]);
  g[0][0][1] = min(x[0] + y[1], x[1] + y[3]);
  g[0][0][2] = min(x[2] + y[0], x[3] + y[2]);
  g[0][0][3] = min(x[2] + y[1], x[3] + y[3]);
  memcpy(z, g[0][0], 32);
}
long long LCA(int x, int y, int st) {
  memset(X, 0, sizeof(X)), memset(Y, 0, sizeof(Y));
  if (deep[x] < deep[y]) swap(x, y), st = fz[st];
  for (int i = 19; i >= 0; i--) {
    if (deep[F[x][i]] < deep[y]) continue;
    merge(X, g[i][x], X);
    x = F[x][i];
  }
  if (x == y) return X[st];
  for (int i = 19; i >= 0; i--) {
    if (F[x][i] ^ F[y][i]) {
      merge(X, g[i][x], X), merge(Y, g[i][y], Y);
      x = F[x][i], y = F[y][i];
    }
  }
  merge(X, g[0][x], X), merge(Y, g[0][y], Y);
  swap(Y[1], Y[2]);
  merge(X, Y, X);
  return X[st];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &dp[i]);
  for (int i = 1; i < n; i++) {
    int a, b;
    long long w1, w2;
    scanf("%d%d%lld%lld", &a, &b, &w1, &w2);
    add(a, b, w1, w2), add(b, a, w1, w2);
  }
  dfs1(1, 0), dfs2(1, 0);
  dfs3(1, 0);
  for (int j = 1; j <= 19; j++) {
    for (int i = 1; i <= n; i++) {
      int x = i, y = F[i][j - 1];
      if (!y || !F[x][j]) continue;
      merge(g[j - 1][x], g[j - 1][y], g[j][x]);
    }
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if ((a + 1) / 2 == (b + 1) / 2) {
      printf("%lld\n", dp[a + 1 >> 1]);
      continue;
    }
    int st = (a & 1) << 1 | (b & 1);
    a = a + 1 >> 1, b = b + 1 >> 1;
    printf("%lld\n", LCA(a, b, st ^ 3));
  }
  return 0;
}