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>
int N, Q, head[300001], next[599999], to[599999], E, del[300001];
long long a[300001], w[599999][2], O[600001];
int q[300001], fa[300001], size[300001], mxson[300001], belong[300001];
void DP() {
  int H = 0, T = 1, u;
  q[1] = 1;
  while (H < T)
    for (int e = head[u = q[++H]]; e; e = next[e])
      if (to[e] != fa[u]) fa[q[++T] = to[e]] = u;
  for (int i = N; i; i--) {
    int u = q[i];
    for (int e = head[u]; e; e = next[e])
      if (to[e] != fa[u]) a[u] = std::min(a[u], a[to[e]] + w[e][0] + w[e][1]);
  }
  for (int i = 1; i <= N; i++) {
    int u = q[i];
    for (int e = head[u]; e; e = next[e])
      if (to[e] != fa[u])
        a[to[e]] = std::min(a[to[e]], a[u] + w[e][0] + w[e][1]);
  }
}
struct query {
  int u, du, v, dv, id;
} p[600001];
int qaq(int p) {
  int H = 0, T = 1, u;
  q[1] = p;
  while (H < T)
    for (int e = head[u = q[++H]]; e; e = next[e])
      if (!del[to[e]] && to[e] != fa[u]) fa[q[++T] = to[e]] = u;
  for (int i = 1; i <= T; i++) {
    size[q[i]] = 1;
    mxson[q[i]] = 0;
  }
  for (int i = T; i; i--) {
    if (mxson[q[i]] << 1 <= T && size[q[i]] << 1 >= T) return q[i];
    size[fa[q[i]]] += size[q[i]];
    mxson[fa[q[i]]] = std::max(mxson[fa[q[i]]], size[q[i]]);
  }
  return 0;
}
std::vector<query> distri_query[600001];
long long f[300001][2], g[300001][2];
void trans(int fa, int p, int e) {
  f[p][0] = std::min(f[fa][0] + w[e][0], f[fa][1] + w[e][1] + a[p]);
  f[p][1] = std::min(f[fa][1] + w[e][1], f[fa][0] + w[e][0] + a[p]);
  g[p][0] = std::min(g[fa][0] + w[e][0], g[fa][1] + w[e][1] + a[p]);
  g[p][1] = std::min(g[fa][1] + w[e][1], g[fa][0] + w[e][0] + a[p]);
}
void qwq(int p, std::vector<query> vq) {
  p = qaq(p);
  del[p] = 1;
  belong[p] = 0;
  f[p][0] = g[p][1] = 0;
  f[p][1] = g[p][0] = a[p];
  for (int e = head[p]; e; e = next[e])
    if (!del[to[e]]) {
      distri_query[to[e]].clear();
      int H = 0, T = 1, u;
      q[1] = to[e];
      fa[to[e]] = p;
      belong[to[e]] = to[e];
      trans(p, to[e], e);
      while (H < T)
        for (int e = head[u = q[++H]]; e; e = next[e])
          if (!del[to[e]] && to[e] != fa[u]) {
            fa[q[++T] = to[e]] = u;
            belong[to[e]] = belong[u];
            trans(u, to[e], e);
          }
    }
  for (auto &i : vq)
    if (belong[i.u] != belong[i.v] || belong[i.u] == 0 || belong[i.v] == 0)
      O[i.id] =
          std::min(f[i.u][i.du] + f[i.v][i.dv], g[i.u][i.du] + g[i.v][i.dv]);
    else
      distri_query[belong[i.u]].push_back(i);
  for (int e = head[p]; e; e = next[e])
    if (!del[to[e]]) qwq(to[e], distri_query[to[e]]);
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%lld", a + i);
  for (int i = 1, u, v; i < N; i++) {
    long long l[2];
    scanf("%d%d%lld%lld", &u, &v, l, l + 1);
    next[++E] = head[u], to[E] = v, std::copy(l, l + 2, w[E]), head[u] = E;
    next[++E] = head[v], to[E] = u, std::copy(l, l + 2, w[E]), head[v] = E;
  }
  DP();
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    p[i] = (query){u + 1 >> 1, u + 1 & 1, v + 1 >> 1, v + 1 & 1, i};
  }
  qwq(1, std::vector<query>(p + 1, p + Q + 1));
  for (int i = 1; i <= Q; i++) printf("%lld\n", O[i]);
  return 0;
}