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 N = 3 * 1000 * 100 + 10, LG = 20;
int n, par[N][LG], h[N];
long long c[N];
struct edge {
  int u;
  long long w[2];
  edge(int a = 0, long long b = 0, long long c = 0) {
    u = a, w[0] = b, w[1] = c;
  }
};
vector<edge> adj[N];
struct DP {
  long long val[2][2];
  DP() {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) val[i][j] = 1LL << 61;
  }
  void clear() {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) val[i][j] = 0;
  }
  void merge(DP L, DP R) {
    *this = DP();
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          val[i][j] = min(val[i][j], L.val[i][k] + R.val[k][j]);
  }
  void init(int v, int u, long long w[2]) {
    *this = DP();
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int e = 0; e < 2; e++) {
          long long tmp = 0;
          if (i != e) tmp += c[v];
          if (j != e) tmp += c[u];
          tmp += w[e];
          val[i][j] = min(val[i][j], tmp);
        }
  }
  void rot() { swap(val[0][1], val[1][0]); }
  void init(int v) {
    clear();
    val[0][1] = val[1][0] += c[v];
  }
  void debug() {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        cout << i << ' ' << j << ' ' << val[i][j] << '\n';
  }
} dp[N][LG];
void dfs(int v) {
  for (int i = 1; i < LG; i++) {
    par[v][i] = par[par[v][i - 1]][i - 1];
    dp[v][i].merge(dp[v][i - 1], dp[par[v][i - 1]][i - 1]);
  }
  for (auto u : adj[v])
    if (u.u != par[v][0]) {
      par[u.u][0] = v, h[u.u] = h[v] + 1;
      dp[u.u][0].init(u.u, v, u.w);
      dfs(u.u);
    }
}
DP k_par(int &v, int k) {
  DP res;
  res.init(v);
  for (int i = 0; i < LG; i++)
    if ((1 << i) & k) {
      res.merge(res, dp[v][i]);
      v = par[v][i];
    }
  return res;
}
DP get(int v, int u, bool &swp) {
  swp = false;
  if (h[v] < h[u]) swap(v, u), swp = true;
  DP L = k_par(v, h[v] - h[u]);
  assert(h[v] <= h[u]);
  if (v == u) return L;
  DP R;
  R.init(u);
  for (int i = LG - 1; i >= 0; i--)
    if (par[v][i] != par[u][i]) {
      L.merge(L, dp[v][i]);
      R.merge(R, dp[u][i]);
      v = par[v][i], u = par[u][i];
    }
  assert(par[v][0] == par[u][0]);
  L.merge(L, dp[v][0]);
  R.merge(R, dp[u][0]);
  R.rot();
  L.merge(L, R);
  return L;
}
long long ans(int v, int u) {
  bool x = v & 1, y = u & 1, swp = false;
  DP res = get(v >> 1, u >> 1, swp);
  if (swp) swap(x, y);
  return res.val[x][y];
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 1, v, u; i < n; i++) {
    long long w[2];
    cin >> v >> u >> w[0] >> w[1];
    --v, --u;
    adj[v].push_back(edge(u, w[0], w[1]));
    adj[u].push_back(edge(v, w[0], w[1]));
  }
  set<pair<long long, int>> q;
  for (int i = 0; i < n; i++) q.insert({c[i], i});
  while (q.size()) {
    auto it = *q.begin();
    q.erase(q.begin());
    int v = it.second;
    for (auto u : adj[v])
      if (c[v] + u.w[0] + u.w[1] < c[u.u]) {
        q.erase({c[u.u], u.u});
        q.insert({c[u.u] = c[v] + u.w[0] + u.w[1], u.u});
      }
  }
  dfs(0);
  int Q;
  cin >> Q;
  while (Q--) {
    int v, u;
    cin >> v >> u;
    --v, --u;
    cout << ans(v, u) << '\n';
  }
  return 0;
}