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>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int n, fa[300005], FA[300005], c[300005], d[300005], in[300005], out[300005],
    a[600005][20], A, b[600005];
long long f[300005][2], g[300005], dp[300005][2][2];
vector<int> v[300005];
vector<long long> e1[300005], e2[300005];
void dfs(int x, int y) {
  d[x] = d[y] + 1;
  in[x] = out[x] = ++A;
  a[A][0] = x;
  for (int i = 0; i < v[x].size(); ++i) {
    if (v[x][i] == y) {
      f[x][0] = e1[x][i], f[x][1] = e2[x][i];
      continue;
    }
    dfs(v[x][i], x);
    out[x] = ++A;
    a[A][0] = x;
  }
}
void upd(int x, int y) {
  for (int i = 0; i < v[x].size(); ++i) {
    if (v[x][i] == y) continue;
    upd(v[x][i], x);
    g[x] = min(g[x], e1[x][i] + g[v[x][i]] + e2[x][i]);
  }
}
void upd2(int x, int y) {
  for (int i = 0; i < v[x].size(); ++i) {
    if (v[x][i] == y) continue;
    g[v[x][i]] = min(g[v[x][i]], e1[x][i] + g[x] + e2[x][i]);
    upd2(v[x][i], x);
  }
}
void dfs2(int x, int y) {
  fa[x] = y;
  if (!c[x]) {
    dp[x][0][1] = dp[x][1][0] = g[x];
    FA[x] = x;
  } else {
    dp[x][0][0] = min(dp[y][0][0] + f[x][0], dp[y][1][0] + f[x][1] + g[x]);
    dp[x][0][1] = min(dp[y][0][1] + f[x][0], dp[y][1][1] + f[x][1] + g[x]);
    dp[x][1][0] = min(dp[y][1][0] + f[x][1], dp[y][0][0] + f[x][0] + g[x]);
    dp[x][1][1] = min(dp[y][1][1] + f[x][1], dp[y][0][1] + f[x][0] + g[x]);
    FA[x] = FA[y];
  }
  for (int i = 0; i < v[x].size(); ++i)
    if (v[x][i] != y) dfs2(v[x][i], x);
}
int get(int x, int y) {
  int k = b[y - x];
  if (d[a[x][k]] > d[a[y - (1 << k) + 1][k]]) return a[y - (1 << k) + 1][k];
  return a[x][k];
}
pair<long long, long long> sol(int x, int X, int y) {
  long long ret[2] = {0, 0};
  ret[X ^ 1] = g[x];
  while (x != y) {
    if (d[FA[x]] < d[y] || FA[x] == x) {
      long long _ = min(ret[0] + f[x][0], ret[1] + f[x][1] + g[fa[x]]),
                __ = min(ret[1] + f[x][1], ret[0] + f[x][0] + g[fa[x]]);
      ret[0] = _, ret[1] = __;
      x = fa[x];
    } else {
      long long _ = min(ret[0] + dp[x][0][0], ret[1] + dp[x][1][0]),
                __ = min(ret[0] + dp[x][0][1], ret[1] + dp[x][1][1]);
      ret[0] = _, ret[1] = __;
      x = FA[x];
    }
  }
  return make_pair(ret[0], ret[1]);
}
int main() {
  for (int i = 1; i <= 600000; ++i) {
    b[i] = b[i - 1];
    if (i == (2 << b[i])) ++b[i];
  }
  scanf("%d", &n);
  c[1] = 0;
  for (int i = 2; i <= n; ++i) c[i] = rand() % 550;
  for (int i = 1; i <= n; ++i) scanf("%I64d", g + i);
  for (int i = 1; i < n; ++i) {
    int x, y;
    long long w1, w2;
    scanf("%d%d%I64d%I64d", &x, &y, &w1, &w2);
    v[x].push_back(y), v[y].push_back(x), e1[x].push_back(w1),
        e1[y].push_back(w1), e2[x].push_back(w2), e2[y].push_back(w2);
  }
  dfs(1, 0);
  upd(1, 0);
  upd2(1, 0);
  dfs2(1, 0);
  for (int k = 0; k < 19; ++k) {
    for (int i = 1; i <= A - (2 << k) + 1; ++i) {
      if (d[a[i][k]] < d[a[i + (1 << k)][k]])
        a[i][k + 1] = a[i][k];
      else
        a[i][k + 1] = a[i + (1 << k)][k];
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int x, X, y, Y, z;
    scanf("%d%d", &x, &y);
    if (x & 1)
      X = 0;
    else
      X = 1;
    if (y & 1)
      Y = 0;
    else
      Y = 1;
    x = (x + 1) / 2, y = (y + 1) / 2;
    if (in[x] > in[y]) swap(x, y), swap(X, Y);
    z = get(in[x], out[y]);
    pair<long long, long long> p1 = sol(x, X, z), p2 = sol(y, Y, z);
    printf("%I64d\n", min(p1.first + p2.first, p1.second + p2.second));
  }
  return 0;
}