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 N = 3e5 + 2, M = 6e5 + 2, O = 1.2e6 + 2;
long long len1[M], len2[M], v[N], g[N][4], ans[M];
long long lx, ly;
int lj[M], nxt[M], fir[N], f[N], qlj[O], qnxt[O], qfir[N], xw[O][3];
int flj[M], fnxt[M], ffir[N];
int n, q, i, x, y, c, bs, qs, fs;
bool ed[N];
inline void read(int &x) {
  c = getchar();
  while ((c < 48) || (c > 57)) c = getchar();
  x = c ^ 48;
  c = getchar();
  while ((c >= 48) && (c <= 57)) {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
}
inline void read(long long &x) {
  c = getchar();
  while ((c < 48) || (c > 57)) c = getchar();
  x = c ^ 48;
  c = getchar();
  while ((c >= 48) && (c <= 57)) {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
}
inline void add() {
  lj[++bs] = y;
  len1[bs] = lx;
  len2[bs] = ly;
  nxt[bs] = fir[x];
  fir[x] = bs;
  lj[++bs] = x;
  len1[bs] = lx;
  len2[bs] = ly;
  nxt[bs] = fir[y];
  fir[y] = bs;
}
inline void fadd(int x, int y) {
  flj[++fs] = y;
  fnxt[fs] = ffir[x];
  ffir[x] = fs;
}
inline void qadd(int x, int y, int i) {
  qlj[++qs] = i;
  qnxt[qs] = qfir[x];
  qfir[x] = qs;
}
void dfs1(int x) {
  ed[x] = 1;
  for (int i = fir[x]; i; i = nxt[i])
    if (!ed[lj[i]]) {
      dfs1(lj[i]);
      v[x] = min(v[x], v[lj[i]] + len1[i] + len2[i]);
    }
  ed[x] = 0;
}
void dfs2(int x) {
  ed[x] = 1;
  for (int i = fir[x]; i; i = nxt[i])
    if (!ed[lj[i]]) {
      v[lj[i]] = min(v[lj[i]], v[x] + len1[i] + len2[i]);
      dfs2(lj[i]);
    }
  ed[x] = 0;
}
void dfs3(int x) {
  ed[x] = 1;
  for (int i = fir[x]; i; i = nxt[i])
    if (!ed[lj[i]]) {
      g[lj[i]][0] = min(len2[i], v[x] + v[lj[i]] + len1[i]);
      g[lj[i]][1] = min(len2[i] + v[lj[i]], len1[i] + v[x]);
      g[lj[i]][2] = min(len1[i] + v[lj[i]], len2[i] + v[x]);
      g[lj[i]][3] = min(len1[i], v[x] + v[lj[i]] + len2[i]);
      dfs3(lj[i]);
    }
  ed[x] = 0;
}
void getf(register int x) {
  if (f[f[x]] == f[x]) return;
  getf(f[x]);
  g[0][0] = min(g[x][0] + g[f[x]][0], g[x][2] + g[f[x]][1]);
  g[0][1] = min(g[x][1] + g[f[x]][0], g[x][3] + g[f[x]][1]);
  g[0][2] = min(g[x][0] + g[f[x]][2], g[x][2] + g[f[x]][3]);
  g[0][3] = min(g[x][1] + g[f[x]][2], g[x][3] + g[f[x]][3]);
  memcpy(g[x], g[0], 32);
  f[x] = f[f[x]];
}
void dfs4(int x) {
  ed[x] = 1;
  int i;
  for (i = qfir[x]; i; i = qnxt[i])
    if (ed[y = xw[qlj[i]][2]]) {
      getf(y);
      fadd(f[y], qlj[i]);
    }
  for (i = fir[x]; i; i = nxt[i])
    if (!ed[lj[i]]) {
      dfs4(lj[i]);
      f[lj[i]] = x;
    }
  for (i = ffir[x]; i; i = fnxt[i]) {
    y = flj[i];
    if (y > q)
      c = y - q;
    else
      c = y;
    if (xw[y][2] != x) {
      qs = xw[y][0] >> 1 & 1;
      bs = xw[y][0] & 1;
      getf(xw[y][1]);
      getf(xw[y][2]);
      ans[c] = min(g[xw[y][1]][bs] + g[xw[y][2]][qs],
                   g[xw[y][1]][bs | 2] + g[xw[y][2]][qs | 2]);
    } else {
      getf(xw[y][1]);
      ans[c] = g[xw[y][1]][xw[y][0]];
    }
  }
}
int main() {
  read(n);
  for (i = 1; i <= n; i++) read(v[i]);
  for (i = 1; i < n; i++) {
    read(x);
    read(y);
    read(lx);
    read(ly);
    add();
    f[i] = i;
  }
  dfs1(1);
  dfs2(1);
  dfs3(1);
  read(q);
  for (i = 1; i <= q; i++) {
    read(x);
    read(y);
    if (x + 1 >> 1 == y + 1 >> 1) {
      if (x != y) ans[i] = v[x + 1 >> 1];
      continue;
    }
    xw[i][0] = (x & 1) | (y & 1) << 1;
    xw[i + q][0] = (y & 1) | (x & 1) << 1;
    qadd(xw[i][1] = xw[i + q][2] = x = x + 1 >> 1,
         xw[i][2] = xw[i + q][1] = y = y + 1 >> 1, i);
    qadd(y, x, i + q);
  }
  dfs4(1);
  for (i = 1; i <= q; i++) printf("%lld\n", ans[i]);
}