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;
string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
const int INF = 1e9 + 7, N = 3e5 + 7;
const long long oo = 1e18;
long long w[N];
long long dp[N];
vector<pair<int, pair<long long, long long>>> G[N];
pair<long long, long long> pe[N];
int p[N][20], d[N];
struct Data {
  long long a[2][2];
  Data(long long a00 = oo, long long a01 = oo, long long a10 = oo,
       long long a11 = oo) {
    a[0][0] = a00, a[0][1] = a01, a[1][0] = a10, a[1][1] = a11;
  }
  friend Data operator+(Data lhs, Data rhs) {
    Data res;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          res.a[i][k] = min(res.a[i][k], lhs.a[i][j] + rhs.a[j][k]);
    return res;
  }
  void transpose() { swap(a[0][1], a[1][0]); }
} up[N][20], self[N];
string to_string(Data d) {
  return "(" + to_string(d.a[0][0]) + ", " + to_string(d.a[0][1]) + ", " +
         to_string(d.a[1][0]) + ", " + to_string(d.a[1][1]) + ")";
}
void dfs(int u, int pa = 0, int depth = 0) {
  p[u][0] = pa, d[u] = depth;
  for (int i = 1; i < 20; i++) p[u][i] = p[p[u][i - 1]][i - 1];
  dp[u] = w[u];
  for (auto [v, ws] : G[u])
    if (v != pa) {
      pe[v] = ws;
      dfs(v, u, depth + 1);
      dp[u] = min(dp[u], dp[v] + ws.first + ws.second);
    }
}
void dfs2(int u, int pa = 0, long long dp_up = oo) {
  dp[u] = min(dp[u], dp_up);
  for (auto [v, ws] : G[u])
    if (v != pa) {
      dfs2(v, u, dp[u] + ws.first + ws.second);
    }
}
int lca(int u, int v) {
  if (d[u] > d[v]) swap(u, v);
  assert(d[v] >= d[u]);
  for (int i = 0; i < 20; i++)
    if ((d[v] - d[u]) >> i & 1) v = p[v][i];
  assert(d[v] == d[u]);
  if (u == v) return u;
  for (int i = 19; i >= 0; i--)
    if (p[u][i] != p[v][i]) u = p[u][i], v = p[v][i];
  assert(p[u][0] == p[v][0]);
  return p[u][0];
}
Data go_up(int u, int step) {
  Data res = self[u];
  for (int i = 0; i < 20; i++)
    if (step >> i & 1) {
      res = res + up[u][i];
      u = p[u][i];
    }
  return res;
}
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    long long w1, w2;
    cin >> u >> v >> w1 >> w2;
    G[u].emplace_back(v, make_pair(w1, w2));
    G[v].emplace_back(u, make_pair(w1, w2));
  }
  dfs(1);
  dfs2(1);
  for (int i = 1; i <= n; i++) self[i] = Data(0, dp[i], dp[i], 0);
  for (int i = 2; i <= n; i++) {
    up[i][0] = Data(pe[i].first, oo, oo, pe[i].second) + self[p[i][0]];
  }
  for (int j = 1; j < 20; j++)
    for (int i = 1; i <= n; i++)
      if (p[i][j]) up[i][j] = up[i][j - 1] + up[p[i][j - 1]][j - 1];
  int q;
  cin >> q;
  while (q--) {
    int u, v;
    cin >> u >> v;
    assert(u != v);
    pair<int, int> uu = {(u - 1) / 2 + 1, (u - 1) & 1};
    pair<int, int> vv = {(v - 1) / 2 + 1, (v - 1) & 1};
    if (uu.first == vv.first) {
      cout << dp[uu.first] << '\n';
      continue;
    }
    int l = lca(uu.first, vv.first);
    Data up = go_up(uu.first, d[uu.first] - d[l]),
         down = go_up(vv.first, d[vv.first] - d[l]);
    down.transpose();
    Data res = up + down;
    cout << res.a[uu.second][vv.second] << '\n';
  }
}