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>
inline int read() {
  char c = getchar();
  int x = 0, ft = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') ft = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x * ft;
}
inline long long ll_read() {
  char c = getchar();
  long long x = 0, ft = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') ft = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x * ft;
}
inline long long min(long long a, long long b) { return a < b ? a : b; }
const int N = 3e5 + 5;
int n, h[N], edge_cnt, fa[20][N], d[N];
long long tran[N];
struct Edge {
  int to, nex;
  long long w0, w1;
} e[N << 1];
inline void add_edge(int u, int v, long long w0, long long w1) {
  e[++edge_cnt] = (Edge){v, h[u], w0, w1};
  h[u] = edge_cnt;
}
void dfs1(int u, int pre) {
  for (int i = h[u]; i; i = e[i].nex) {
    int v = e[i].to;
    if (v == pre) continue;
    dfs1(v, u);
    tran[u] = min(tran[u], tran[v] + e[i].w0 + e[i].w1);
  }
}
void dfs2(int u, int pre) {
  for (int i = h[u]; i; i = e[i].nex) {
    int v = e[i].to;
    if (v == pre) continue;
    tran[v] = min(tran[v], tran[u] + e[i].w0 + e[i].w1);
    dfs2(v, u);
  }
}
struct Mat {
  long long m[2][2];
} to[20][N];
inline Mat operator*(Mat a, Mat b) {
  Mat c;
  for (int i = 0; i <= 1; ++i)
    for (int j = 0; j <= 1; ++j) {
      c.m[i][j] = min(a.m[i][0] + b.m[0][j], a.m[i][1] + b.m[1][j]);
    }
  return c;
}
void dfs3(int u, int pre, long long w0, long long w1) {
  d[u] = d[pre] + 1;
  if (pre) {
    fa[0][u] = pre;
    for (int j = 1; j <= 18; ++j)
      if (fa[j - 1][fa[j - 1][u]]) {
        fa[j][u] = fa[j - 1][fa[j - 1][u]];
      }
    to[0][u].m[0][0] = min(w0, tran[u] + w1 + tran[pre]);
    to[0][u].m[0][1] = min(w0 + tran[pre], tran[u] + w1);
    to[0][u].m[1][0] = min(tran[u] + w0, w1 + tran[pre]);
    to[0][u].m[1][1] = min(tran[u] + w0 + tran[pre], w1);
    for (int j = 1; j <= 18; ++j)
      if (fa[j - 1][fa[j - 1][u]]) {
        to[j][u] = to[j - 1][u] * to[j - 1][fa[j - 1][u]];
      }
  }
  for (int i = h[u]; i; i = e[i].nex) {
    int v = e[i].to;
    if (v == pre) continue;
    dfs3(v, u, e[i].w0, e[i].w1);
  }
}
inline int get_lca(int x, int y) {
  if (d[x] < d[y]) std::swap(x, y);
  int del = d[x] - d[y];
  for (int j = 18; ~j; --j)
    if ((del >> j) & 1) x = fa[j][x];
  if (x == y) return x;
  for (int j = 18; ~j; --j)
    if (fa[j][x] ^ fa[j][y]) {
      x = fa[j][x];
      y = fa[j][y];
    }
  return fa[0][x];
}
inline Mat up(int u, int v) {
  Mat res;
  int del = d[u] - d[v];
  res.m[0][0] = 0;
  res.m[0][1] = tran[u];
  res.m[1][0] = tran[u];
  res.m[1][1] = 0;
  for (int j = 18; ~j; --j)
    if ((del >> j) & 1) {
      res = res * to[j][u];
      u = fa[j][u];
    }
  return res;
}
inline Mat T(Mat x) {
  std::swap(x.m[0][1], x.m[1][0]);
  return x;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) tran[i] = ll_read();
  for (int i = 1; i < n; ++i) {
    int u = read(), v = read();
    long long w1 = ll_read(), w0 = ll_read();
    add_edge(u, v, w0, w1);
    add_edge(v, u, w0, w1);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  dfs3(1, 0, 0, 0);
  for (int i = 1, q = read(); i <= q; ++i) {
    int u = read(), v = read(), lca = get_lca((u + 1) / 2, (v + 1) / 2);
    Mat res = up((u + 1) / 2, lca) * T(up((v + 1) / 2, lca));
    printf("%lld\n", res.m[u % 2][v % 2]);
  }
  return 0;
}