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>
const int Maxn = 300000;
const int Maxm = 600000;
const int Maxq = 1200000;
long long w[Maxn + 5];
long long f[Maxn + 5][20][2][2];
long long f_x[2], f_y[2], d[Maxn + 5];
long long n;
long long fa[Maxn + 5][20], dep[Maxn + 5];
long long head[Maxn + 5], arrive[Maxn << 1 | 5], val_1[Maxn << 1 | 5],
    val_2[Maxn << 1 | 5], nxt[Maxn << 1 | 5], tot;
void add_edge(long long from, long long to, long long w_1, long long w_2) {
  arrive[++tot] = to;
  nxt[tot] = head[from];
  val_1[tot] = w_1;
  val_2[tot] = w_2;
  head[from] = tot;
}
void init_dfs_1(long long u) {
  dep[u] = dep[fa[u][0]] + 1;
  for (long long i = 1; fa[fa[u][i - 1]][i - 1]; i++) {
    fa[u][i] = fa[fa[u][i - 1]][i - 1];
  }
  for (long long i = head[u]; i; i = nxt[i]) {
    long long v = arrive[i];
    if (v == fa[u][0]) {
      continue;
    }
    fa[v][0] = u;
    init_dfs_1(v);
    w[u] = std::min(w[u], w[v] + val_1[i] + val_2[i]);
  }
}
void init_dfs_2(long long u) {
  for (long long i = head[u]; i; i = nxt[i]) {
    long long v = arrive[i];
    if (v == fa[u][0]) {
      continue;
    }
    w[v] = std::min(w[v], w[u] + val_1[i] + val_2[i]);
    init_dfs_2(v);
  }
}
void work_dfs(long long u) {
  for (long long i = head[u]; i; i = nxt[i]) {
    long long v = arrive[i];
    if (v == fa[u][0]) {
      continue;
    }
    work_dfs(v);
    f[v][0][0][0] = std::min(val_1[i], w[v] + val_2[i] + w[u]);
    f[v][0][0][1] = std::min(w[v] + val_2[i], w[u] + val_1[i]);
    f[v][0][1][0] = std::min(w[v] + val_1[i], w[u] + val_2[i]);
    f[v][0][1][1] = std::min(val_2[i], w[v] + val_1[i] + w[u]);
  }
}
long long find_lca(long long u, long long v) {
  if (dep[u] < dep[v]) {
    std::swap(u, v);
  }
  for (long long i = 19; i >= 0; i--) {
    if (dep[fa[u][i]] >= dep[v]) {
      u = fa[u][i];
    }
  }
  if (u == v) {
    return u;
  }
  for (long long i = 19; i >= 0; i--) {
    if (fa[u][i] != fa[v][i]) {
      u = fa[u][i], v = fa[v][i];
    }
  }
  return fa[u][0];
}
void solve() {
  long long u, v, op_u, op_v;
  scanf("%lld%lld", &u, &v);
  op_u = (u & 1) ^ 1, op_v = (v & 1) ^ 1;
  u = (u + 1) >> 1, v = (v + 1) >> 1;
  long long lca = find_lca(u, v);
  f_x[op_u] = f_y[op_v] = 0;
  f_x[op_u ^ 1] = w[u], f_y[op_v ^ 1] = w[v];
  for (long long i = 19; i >= 0; i--) {
    if (dep[fa[u][i]] >= dep[lca]) {
      long long tmp_0 = f_x[0], tmp_1 = f_x[1];
      f_x[0] = std::min(tmp_0 + f[u][i][0][0], tmp_1 + f[u][i][1][0]);
      f_x[1] = std::min(tmp_0 + f[u][i][0][1], tmp_1 + f[u][i][1][1]);
      u = fa[u][i];
    }
  }
  for (long long i = 19; i >= 0; i--) {
    if (dep[fa[v][i]] >= dep[lca]) {
      long long tmp_0 = f_y[0], tmp_1 = f_y[1];
      f_y[0] = std::min(tmp_0 + f[v][i][0][0], tmp_1 + f[v][i][1][0]);
      f_y[1] = std::min(tmp_0 + f[v][i][0][1], tmp_1 + f[v][i][1][1]);
      v = fa[v][i];
    }
  }
  printf("%lld\n", std::min(f_x[0] + f_y[0], f_y[1] + f_x[1]));
}
signed main() {
  memset(f, 0x3f, sizeof f);
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &w[i]);
  }
  for (long long i = 1; i < n; i++) {
    long long u, v, a, b;
    scanf("%lld%lld%lld%lld", &u, &v, &a, &b);
    add_edge(u, v, a, b), add_edge(v, u, a, b);
  }
  init_dfs_1(1);
  init_dfs_2(1);
  work_dfs(1);
  for (long long i = 1; i < 20; i++) {
    for (long long j = 1; j <= n; j++) {
      f[j][i][0][0] =
          std::min(f[j][i - 1][0][0] + f[fa[j][i - 1]][i - 1][0][0],
                   f[j][i - 1][0][1] + f[fa[j][i - 1]][i - 1][1][0]);
      f[j][i][0][1] =
          std::min(f[j][i - 1][0][0] + f[fa[j][i - 1]][i - 1][0][1],
                   f[j][i - 1][0][1] + f[fa[j][i - 1]][i - 1][1][1]);
      f[j][i][1][0] =
          std::min(f[j][i - 1][1][0] + f[fa[j][i - 1]][i - 1][0][0],
                   f[j][i - 1][1][1] + f[fa[j][i - 1]][i - 1][1][0]);
      f[j][i][1][1] =
          std::min(f[j][i - 1][1][0] + f[fa[j][i - 1]][i - 1][0][1],
                   f[j][i - 1][1][1] + f[fa[j][i - 1]][i - 1][1][1]);
    }
  }
  long long T;
  scanf("%lld", &T);
  for (long long t = 1; t <= T; t++) {
    solve();
  }
  return 0;
}