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 MAX = 3e5 + 5;
struct q {
  int x, y;
  long long d1, d2;
} c[MAX << 1];
struct p {
  long long l___, _l__, __l_, ___l;
  p(long long l1 = 0, long long l2 = 0, long long l3 = 0, long long l4 = 0) {
    l___ = l1, _l__ = l2, __l_ = l3, ___l = l4;
  }
} F[20][MAX];
int n, Q, num;
int h[MAX], d[MAX];
long long val[MAX];
int f[20][MAX];
set<int> s;
long long min(long long a, long long b) { return a < b ? a : b; }
p operator+(p a, p b) {
  p c;
  c.l___ = min(a.l___ + b.l___, a._l__ + b.__l_);
  c._l__ = min(a.l___ + b._l__, a._l__ + b.___l);
  c.__l_ = min(a.___l + b.__l_, a.__l_ + b.l___);
  c.___l = min(a.___l + b.___l, a.__l_ + b._l__);
  return c;
}
long long read() {
  long long x(0);
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    ;
  for (; isdigit(ch); x = x * 10 + ch - 48, ch = getchar())
    ;
  return x;
}
void dfs(int x = 1, int fa = 0) {
  f[0][x] = fa, d[x] = d[fa] + 1;
  for (int i = h[x], y; i; i = c[i].x)
    if ((y = c[i].y) != fa) {
      dfs(y, x);
      F[0][y].l___ = min(c[i].d1, val[x] + c[i].d2 + val[y]);
      F[0][y]._l__ = min(val[y] + c[i].d2, val[x] + c[i].d1);
      F[0][y].__l_ = min(c[i].d2 + val[x], c[i].d1 + val[y]);
      F[0][y].___l = min(val[x] + c[i].d1 + val[y], c[i].d2);
    }
}
void add(int x, int y, long long d1, long long d2) {
  c[++num] = (q){h[x], y, d1, d2}, h[x] = num;
  c[++num] = (q){h[y], x, d1, d2}, h[y] = num;
}
void Init() {
  for (int i = 1; i <= 19; ++i)
    for (int j = 1; j <= n; ++j)
      f[i][j] = f[i - 1][f[i - 1][j]],
      F[i][j] = F[i - 1][j] + F[i - 1][f[i - 1][j]];
}
void Solve(int ux, int uy) {
  int x = ux + 1 >> 1, y = uy + 1 >> 1, H;
  if (d[x] < d[y]) swap(x, y), swap(ux, uy);
  p dx = p(0, val[x], val[x], 0), dy = p(0, val[y], val[y], 0);
  H = d[x] - d[y];
  for (int i = 19; i >= 0; --i)
    if (H & (1 << i)) dx = dx + F[i][x], x = f[i][x];
  if (x != y) {
    for (int i = 19; i >= 0; --i)
      if (f[i][x] != f[i][y])
        dx = dx + F[i][x], dy = dy + F[i][y], x = f[i][x], y = f[i][y];
    dx = dx + F[0][x], dy = dy + F[0][y];
  }
  if ((ux & 1) && (uy & 1))
    printf("%I64d\n", min(dx.l___ + dy.l___, dx._l__ + dy._l__));
  if ((ux & 1) && !(uy & 1))
    printf("%I64d\n", min(dx.l___ + dy.__l_, dx._l__ + dy.___l));
  if (!(ux & 1) && (uy & 1))
    printf("%I64d\n", min(dx.___l + dy._l__, dx.__l_ + dy.l___));
  if (!(ux & 1) && !(uy & 1))
    printf("%I64d\n", min(dx.___l + dy.___l, dx.__l_ + dy.__l_));
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) s.insert(i), val[i] = read();
  for (int i = 1, x, y; i < n; ++i) {
    x = read(), y = read();
    long long d1 = read(), d2 = read();
    add(x, y, d1, d2);
  }
  while (!s.empty()) {
    int tt = *s.begin();
    s.erase(tt);
    for (int i = h[tt], y; i; i = c[i].x)
      if (val[y = c[i].y] > val[tt] + c[i].d1 + c[i].d2)
        s.erase(y), val[y] = val[tt] + c[i].d1 + c[i].d2, s.insert(y);
  }
  dfs(), Init(), Q = read();
  for (int i = 1; i <= Q; ++i) Solve(read(), read());
  return 0;
}