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;
inline long long read() {
  long long x = 0, y = 0, c = getchar();
  while (!isdigit(c)) y = c, c = getchar();
  while (isdigit(c)) x = x * 10 + (c ^ '0'), c = getchar();
  return y == '-' ? -x : x;
}
inline void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
int n, m;
long long a[600010], b[600010];
struct edge {
  int to, nxt;
  long long v1, v2;
} e[600010];
int cnt = 1, fir[600010];
inline void ins(int u, int v, long long w, long long x) {
  e[++cnt].to = v;
  e[cnt].nxt = fir[u];
  fir[u] = cnt;
  e[cnt].v1 = w;
  e[cnt].v2 = x;
  e[++cnt].to = u;
  e[cnt].nxt = fir[v];
  fir[v] = cnt;
  e[cnt].v1 = w;
  e[cnt].v2 = x;
}
int fa[600010], f[600010], l[600010], r[600010], wz[600010], ed[600010], nw;
bool c[600010];
long long pp[600010][2][2];
long long d1[600010], d2[600010], v1[600010], v2[600010];
long long t[1200010], d[1200010];
inline void psc(int q) {
  if (!d[q]) return;
  t[q << 1] += d[q];
  d[q << 1] += d[q];
  t[q << 1 | 1] += d[q];
  d[q << 1 | 1] += d[q];
  d[q] = 0;
}
inline void xg(int q, int l, int r, int al, int ar, long long x) {
  if (al > ar) return;
  if (l >= al && r <= ar) {
    t[q] += x;
    d[q] += x;
    return;
  }
  psc(q);
  int mid = l + r >> 1;
  if (mid >= al) xg(q << 1, l, mid, al, ar, x);
  if (mid < ar) xg(q << 1 | 1, mid + 1, r, al, ar, x);
  t[q] = min(t[q << 1], t[q << 1 | 1]);
}
inline void dfs(int q) {
  wz[q] = ++nw;
  xg(1, 1, n, wz[q], wz[q], d1[q] + d2[q] + a[q]);
  for (int i = fir[q]; i; i = e[i].nxt)
    if (e[i].to != fa[q]) {
      fa[e[i].to] = q;
      int tmp = n + (i >> 1);
      f[tmp] = q;
      f[e[i].to] = tmp;
      pp[tmp][0][1] = pp[tmp][1][0] = 987654321987654321ll;
      pp[tmp][0][0] = v1[tmp] = e[i].v1;
      pp[tmp][1][1] = v2[tmp] = e[i].v2;
      d1[e[i].to] = d1[q] + e[i].v1;
      d2[e[i].to] = d2[q] + e[i].v2;
      dfs(e[i].to);
    }
  ed[q] = nw;
}
inline void dfs2(int q) {
  b[q] = t[1];
  for (int i = fir[q]; i; i = e[i].nxt)
    if (e[i].to != fa[q]) {
      xg(1, 1, n, wz[e[i].to], ed[e[i].to], -e[i].v1 - e[i].v2);
      xg(1, 1, n, 1, wz[e[i].to] - 1, e[i].v1 + e[i].v2);
      xg(1, 1, n, ed[e[i].to] + 1, n, e[i].v1 + e[i].v2);
      dfs2(e[i].to);
      xg(1, 1, n, wz[e[i].to], ed[e[i].to], e[i].v1 + e[i].v2);
      xg(1, 1, n, 1, wz[e[i].to] - 1, -e[i].v1 - e[i].v2);
      xg(1, 1, n, ed[e[i].to] + 1, n, -e[i].v1 - e[i].v2);
    }
}
inline bool is(int q) { return l[f[q]] != q && r[f[q]] != q; }
long long tpp[2][2];
inline void ud(int q) {
  if (q <= n) {
    pp[q][0][0] = pp[q][1][1] = 0;
    pp[q][0][1] = pp[q][1][0] = b[q];
  } else {
    pp[q][0][1] = pp[q][1][0] = 987654321987654321ll;
    pp[q][0][0] = v1[q];
    pp[q][1][1] = v2[q];
  }
  if (l[q]) {
    tpp[0][0] = min(pp[l[q]][0][0] + pp[q][0][0], pp[l[q]][0][1] + pp[q][1][0]);
    tpp[0][1] = min(pp[l[q]][0][0] + pp[q][0][1], pp[l[q]][0][1] + pp[q][1][1]);
    tpp[1][0] = min(pp[l[q]][1][0] + pp[q][0][0], pp[l[q]][1][1] + pp[q][1][0]);
    tpp[1][1] = min(pp[l[q]][1][0] + pp[q][0][1], pp[l[q]][1][1] + pp[q][1][1]);
    memcpy(pp[q], tpp, sizeof(pp[q]));
  }
  if (r[q]) {
    tpp[0][0] = min(pp[q][0][0] + pp[r[q]][0][0], pp[q][0][1] + pp[r[q]][1][0]);
    tpp[0][1] = min(pp[q][0][0] + pp[r[q]][0][1], pp[q][0][1] + pp[r[q]][1][1]);
    tpp[1][0] = min(pp[q][1][0] + pp[r[q]][0][0], pp[q][1][1] + pp[r[q]][1][0]);
    tpp[1][1] = min(pp[q][1][0] + pp[r[q]][0][1], pp[q][1][1] + pp[r[q]][1][1]);
    memcpy(pp[q], tpp, sizeof(pp[q]));
  }
}
inline void rv(int q) {
  c[q] ^= 1;
  swap(l[q], r[q]);
  swap(pp[q][0][1], pp[q][1][0]);
}
inline void ps(int q) {
  if (!c[q]) return;
  if (l[q]) rv(l[q]);
  if (r[q]) rv(r[q]);
  c[q] = 0;
}
inline void ro(int q) {
  int p = f[q];
  if (l[f[p]] == p)
    l[f[p]] = q;
  else if (r[f[p]] == p)
    r[f[p]] = q;
  f[q] = f[p];
  f[p] = q;
  if (l[p] == q) {
    l[p] = r[q];
    r[q] = p;
    if (l[p]) f[l[p]] = p;
  } else {
    r[p] = l[q];
    l[q] = p;
    if (r[p]) f[r[p]] = p;
  }
  if (is(q)) memcpy(pp[q], pp[p], sizeof(pp[q]));
  ud(p);
}
inline void gx(int q) {
  if (!is(q)) gx(f[q]);
  ps(q);
}
inline void sp(int q) {
  gx(q);
  while (!is(q)) {
    int p = f[q];
    if (!is(p)) {
      if ((l[f[p]] == p) ^ (l[p] == q))
        ro(q);
      else
        ro(p);
    }
    ro(q);
  }
}
inline void ac(int q) {
  int p = 0;
  while (q) {
    sp(q);
    r[q] = p;
    ud(q);
    p = q;
    q = f[q];
  }
}
inline void mk(int q) {
  ac(q);
  sp(q);
  rv(q);
}
inline void si(int u, int v) {
  mk(u);
  ac(v);
  sp(v);
}
int main() {
  int i, j, u, v;
  long long w, x;
  n = read();
  for (i = 1; i <= n; ++i) a[i] = read();
  for (i = 1; i < n; ++i) {
    u = read();
    v = read();
    w = read();
    x = read();
    ins(u, v, w, x);
  }
  dfs(1);
  dfs2(1);
  for (i = 1; i <= n; ++i) pp[i][0][1] = pp[i][1][0] = b[i];
  m = read();
  for (i = 1; i <= m; ++i) {
    u = read() + 1;
    v = read() + 1;
    si(u >> 1, v >> 1);
    print(pp[v >> 1][u & 1][v & 1]);
    putchar('\n');
  }
  return 0;
}