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 MAXN = 300010;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int n, m;
struct edge {
  int ne, to;
  long long w1, w2;
  edge(int N = 0, int T = 0, long long W1 = 0, long long W2 = 0)
      : ne(N), to(T), w1(W1), w2(W2) {}
} e[MAXN << 1];
int fir[MAXN], num = 0;
inline void join(int a, int b, long long c, long long d) {
  e[++num] = edge(fir[a], b, c, d);
  fir[a] = num;
}
long long val[MAXN], f[MAXN][24][2][2];
int anc[MAXN][24], dep[MAXN], lg[MAXN];
void dfs1(int u, int fa) {
  dep[u] = dep[fa] + 1;
  anc[u][0] = fa;
  for (int i = 1; i <= lg[dep[u]]; i++) anc[u][i] = anc[anc[u][i - 1]][i - 1];
  for (int i = fir[u]; i; i = e[i].ne) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs1(v, u);
    val[u] = min(val[u], val[v] + e[i].w1 + e[i].w2);
  }
}
void dfs2(int u, int fa) {
  for (int i = fir[u]; i; i = e[i].ne) {
    int v = e[i].to;
    if (v == fa) continue;
    val[v] = min(val[v], val[u] + e[i].w1 + e[i].w2);
    f[v][0][0][0] = min(e[i].w1, val[u] + e[i].w2 + val[v]);
    f[v][0][0][1] = min(val[v] + e[i].w2, val[u] + e[i].w1);
    f[v][0][1][0] = min(val[v] + e[i].w1, val[u] + e[i].w2);
    f[v][0][1][1] = min(e[i].w2, val[u] + e[i].w1 + val[v]);
    dfs2(v, u);
  }
}
inline int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = lg[dep[x]]; ~i; i--)
    if (dep[anc[x][i]] >= dep[y]) x = anc[x][i];
  if (x == y) return x;
  for (int i = lg[dep[x]]; ~i; i--)
    if (anc[x][i] != anc[y][i]) x = anc[x][i], y = anc[y][i];
  return anc[x][0];
}
inline long long calc(int x, int y) {
  long long nowx[2] = {0, 0}, lax[2] = {0, 0}, nowy[2] = {0, 0},
            lay[2] = {0, 0};
  nowx[x & 1] = val[(x + 1) >> 1];
  nowy[y & 1] = val[(y + 1) >> 1];
  x = (x + 1) >> 1;
  y = (y + 1) >> 1;
  int lca = LCA(x, y);
  for (int i = lg[dep[x]]; ~i; i--)
    if (dep[anc[x][i]] >= dep[lca]) {
      for (int j = 0; j < 2; j++) lax[j] = INF;
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          lax[j] = min(lax[j], nowx[k] + f[x][i][k][j]);
      for (int j = 0; j < 2; j++) nowx[j] = lax[j];
      x = anc[x][i];
    }
  for (int i = lg[dep[y]]; ~i; i--)
    if (dep[anc[y][i]] >= dep[lca]) {
      for (int j = 0; j < 2; j++) lay[j] = INF;
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          lay[j] = min(lay[j], nowy[k] + f[y][i][k][j]);
      for (int j = 0; j < 2; j++) nowy[j] = lay[j];
      y = anc[y][i];
    }
  return min(nowx[0] + nowy[0], nowx[1] + nowy[1]);
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) lg[i] = lg[i >> 1] + 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= lg[n]; j++)
      for (int x = 0; x < 2; x++)
        for (int y = 0; y < 2; y++) f[i][j][x][y] = INF;
  for (int i = 1; i <= n; i++) scanf("%lld", &val[i]);
  for (int i = 1; i < n; i++) {
    int u, v;
    long long x, y;
    scanf("%d%d%lld%lld", &u, &v, &x, &y);
    join(u, v, x, y);
    join(v, u, x, y);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  for (int j = 1; j <= lg[n]; j++) {
    for (int i = 1; i <= n; i++) {
      for (int x = 0; x < 2; x++) {
        for (int y = 0; y < 2; y++) {
          f[i][j][x][y] = INF;
          for (int z = 0; z < 2; z++) {
            f[i][j][x][y] =
                min(f[i][j][x][y],
                    f[i][j - 1][x][z] + f[anc[i][j - 1]][j - 1][z][y]);
          }
        }
      }
    }
  }
  scanf("%d", &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    printf("%lld\n", calc(u, v));
  }
  return 0;
}