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 Nmax = 6e5 + 5;
const long long inf = 1e18;
long long teleport[Nmax], ans[Nmax];
vector<int> v[Nmax];
vector<pair<long long, long long> > edge[Nmax];
int n;
struct qry {
  int x, y;
  bool t1, t2;
  int id;
};
void min_to(long long &x, long long y) {
  if (x > y) x = y;
}
namespace prepare {
void dfs01(int node, int dad = 0) {
  int i;
  for (i = 0; i < v[node].size(); ++i)
    if (v[node][i] != dad) {
      dfs01(v[node][i], node);
      min_to(teleport[node],
             teleport[v[node][i]] + edge[node][i].first + edge[node][i].second);
    }
}
void dfs02(int node, int dad = 0) {
  int i;
  for (i = 0; i < v[node].size(); ++i)
    if (v[node][i] != dad) {
      min_to(teleport[v[node][i]],
             teleport[node] + edge[node][i].first + edge[node][i].second);
      dfs02(v[node][i], node);
    }
}
void compute_teleport() {
  vector<int> ord;
  int i;
  for (i = 1; i <= n; ++i) ord.push_back(i);
  dfs01(1);
  dfs02(1);
}
}  // namespace prepare
namespace centroid_decomp {
static int All, where[Nmax], w[Nmax];
static bool used[Nmax];
static long long dp[Nmax][2][2];
void dfs0(int node, int dad = 0) {
  w[node] = 1;
  for (auto it : v[node])
    if (it != dad && !used[it]) {
      dfs0(it, node);
      w[node] += w[it];
    }
}
pair<int, int> centroid(int node, int dad = 0) {
  int up = All - w[node];
  pair<int, int> ans = {Nmax, Nmax};
  for (auto it : v[node])
    if (it != dad && !used[it]) {
      ans = min(ans, centroid(it, node));
      up = max(up, w[it]);
    }
  ans = min(ans, {up, node});
  return ans;
}
void dfs(int node, int dad) {
  int i, j;
  for (i = 0; i < v[node].size(); ++i)
    if (!used[v[node][i]] && v[node][i] != dad) {
      int son = v[node][i];
      if (!dad)
        where[son] = i;
      else
        where[son] = where[node];
      for (j = 0; j < 2; ++j) {
        dp[son][j][0] = dp[node][j][0] + edge[node][i].first;
        dp[son][j][1] = dp[node][j][1] + edge[node][i].second;
        min_to(dp[son][j][0], dp[son][j][1] + teleport[son]);
        min_to(dp[son][j][1], dp[son][j][0] + teleport[son]);
      }
      dfs(son, node);
    }
}
void solve(int node, vector<qry> &Q) {
  dfs0(node);
  All = w[node];
  node = centroid(node).second;
  dp[node][0][0] = dp[node][1][1] = 0;
  dp[node][0][1] = dp[node][1][0] = inf;
  where[node] = -1;
  dfs(node, 0);
  vector<vector<qry> > toq;
  toq.resize(v[node].size());
  for (auto it : Q)
    if (where[it.x] != -1 && where[it.y] != -1 && where[it.x] == where[it.y])
      toq[where[it.x]].push_back(it);
    else {
      ans[it.id] = inf;
      for (int j = 0; j < 2; ++j)
        for (int k = 0; k < 2; ++k)
          min_to(ans[it.id], dp[it.x][j][it.t1] + dp[it.y][k][it.t2] +
                                 (j != k) * teleport[node]);
    }
  Q.clear();
  Q.shrink_to_fit();
  used[node] = 1;
  for (int i = 0; i < v[node].size(); ++i) {
    int son = v[node][i];
    if (used[son]) continue;
    solve(son, toq[i]);
  }
}
}  // namespace centroid_decomp
int main() {
  cin.sync_with_stdio(false);
  int i, x, y, q;
  long long c1, c2;
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> teleport[i];
  for (i = 1; i < n; ++i) {
    cin >> x >> y >> c1 >> c2;
    edge[x].push_back({c1, c2});
    edge[y].push_back({c1, c2});
    v[x].push_back(y);
    v[y].push_back(x);
  }
  prepare ::compute_teleport();
  vector<qry> queries;
  cin >> q;
  for (i = 1; i <= q; ++i) {
    cin >> x >> y;
    queries.push_back(
        {(x + 1) / 2, (y + 1) / 2, (x % 2 == 0), (y % 2 == 0), i});
  }
  centroid_decomp ::solve(1, queries);
  for (i = 1; i <= q; ++i) cout << ans[i] << '\n';
  return 0;
}