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;
class edge {
 public:
  int e, nxt;
  long long w1, w2;
} g[600010];
int head[300010], ecnt = 0, dep[300010], fa[300010][19];
void addedge(int s, int e, long long w1, long long w2) {
  g[ecnt] = (edge){e, head[s], w1, w2}, head[s] = ecnt++;
  g[ecnt] = (edge){s, head[e], w1, w2}, head[e] = ecnt++;
}
long long d[300010];
class matr {
 public:
  long long dat[2][2];
  void init() { memset(dat, 0, sizeof(dat)); }
  matr operator*(const matr &t) const {
    matr ret;
    memset(ret.dat, 0x3f, sizeof(ret.dat));
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          ret.dat[i][k] = min(ret.dat[i][k], dat[i][j] + t.dat[j][k]);
        }
      }
    }
    return ret;
  }
} st[300010][19];
void dfs1(int np, int fath) {
  dep[np] = dep[fath] + 1;
  for (int i = head[np]; i != -1; i = g[i].nxt) {
    if (g[i].e == fath) continue;
    dfs1(g[i].e, np);
    d[np] = min(d[np], d[g[i].e] + g[i].w1 + g[i].w2);
  }
}
void dfs2(int np, int fath) {
  for (int i = head[np]; i != -1; i = g[i].nxt) {
    if (g[i].e == fath) {
      d[np] = min(d[np], d[fath] + g[i].w1 + g[i].w2);
      break;
    }
  }
  for (int i = head[np]; i != -1; i = g[i].nxt) {
    if (g[i].e == fath) continue;
    dfs2(g[i].e, np);
  }
}
void dfs3(int np, int fath) {
  fa[np][0] = fath;
  for (int i = 1; i < 19; i++) fa[np][i] = fa[fa[np][i - 1]][i - 1];
  for (int i = head[np]; i != -1; i = g[i].nxt) {
    if (g[i].e == fath) {
      st[np][0].dat[0][0] = min(g[i].w1, g[i].w2 + d[np] + d[fath]);
      st[np][0].dat[0][1] = min(g[i].w1 + d[fath], g[i].w2 + d[np]);
      st[np][0].dat[1][0] = min(g[i].w2 + d[fath], g[i].w1 + d[np]);
      st[np][0].dat[1][1] = min(g[i].w2, g[i].w1 + d[np] + d[fath]);
      break;
    }
  }
  for (int i = 1; i < 19; i++)
    st[np][i] = st[np][i - 1] * st[fa[np][i - 1]][i - 1];
  for (int i = head[np]; i != -1; i = g[i].nxt) {
    if (g[i].e == fath) continue;
    dfs3(g[i].e, np);
  }
}
inline int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 18; i >= 0; i--)
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 18; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
int n, Q;
int main() {
  memset(head, 255, sizeof(head));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &d[i]);
  for (int i = 0; i < n - 1; i++) {
    int s, e;
    long long w1, w2;
    scanf("%d%d%lld%lld", &s, &e, &w1, &w2);
    addedge(s, e, w1, w2);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  dfs3(1, 0);
  scanf("%d", &Q);
  while (Q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    int dx = (x + 1) & 1, dy = (y + 1) & 1;
    x = (x + 1) >> 1;
    y = (y + 1) >> 1;
    int L = lca(x, y);
    matr st1, st2;
    st1.init();
    st1.dat[0][1] = st1.dat[1][0] = d[x];
    st2.init();
    st2.dat[0][1] = st2.dat[1][0] = d[y];
    for (int i = 18; i >= 0; i--) {
      if (dep[fa[x][i]] >= dep[L]) st1 = st1 * st[x][i], x = fa[x][i];
      if (dep[fa[y][i]] >= dep[L]) st2 = st2 * st[y][i], y = fa[y][i];
    }
    long long ans = 0x3f3f3f3f3f3f3f3f;
    for (int i = 0; i < 2; i++) ans = min(ans, st1.dat[dx][i] + st2.dat[dy][i]);
    printf("%lld\n", ans);
  }
  return 0;
}