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 maxn = 600001;
int n;
int tot = 0;
int head[maxn];
struct abcd {
  int to, nxt;
  int id;
} table[2 * maxn];
void Add(int x, int y, int z) {
  table[++tot].to = y;
  table[tot].id = z;
  table[tot].nxt = head[x];
  head[x] = tot;
}
long long dj[maxn], ew[2 * maxn][2];
void spfa(int s) {
  memset(dj, 1e9 + 9, sizeof(dj));
  queue<int> Q;
  while (!Q.empty()) Q.pop();
  Q.push(s);
  dj[s] = 0;
  do {
    int u = Q.front();
    Q.pop();
    for (int i = head[u]; i; i = table[i].nxt)
      if (dj[u] + ew[table[i].id][0] + ew[table[i].id][1] < dj[table[i].to]) {
        dj[table[i].to] = dj[u] + ew[table[i].id][0] + ew[table[i].id][1];
        Q.push(table[i].to);
      }
  } while (!Q.empty());
}
void init() { spfa(0); }
int size[maxn], vis[maxn], fa[maxn];
int sum, f[maxn], G;
void getcen(int x, int fa) {
  size[x] = 1;
  f[x] = 0;
  for (int i = head[x]; i; i = table[i].nxt)
    if (table[i].to != fa && !vis[table[i].to]) {
      getcen(table[i].to, x);
      size[x] += size[table[i].to];
      f[x] = max(f[x], size[table[i].to]);
    }
  f[x] = max(f[x], sum - size[x]);
  if (f[x] < f[G]) G = x;
}
vector<int> curq;
vector<int> xq[4 * maxn];
long long dp[2 * maxn][2], ans[2 * maxn];
int last[maxn], qq[2 * maxn][2];
int cnum = 0;
void dfs(int x, int p, int edge) {
  if (vis[x]) return;
  if (p == 0) {
    dp[x * 2][1] = dp[x * 2 - 1][0] = dj[x];
    dp[x * 2][0] = dp[x * 2 - 1][1] = 0;
  } else {
    for (int k = 0; k < 2; k++) {
      dp[x * 2][k] = dp[p * 2][k] + ew[edge][0];
      dp[x * 2 - 1][k] = dp[p * 2 - 1][k] + ew[edge][1];
      dp[x * 2][k] = min(dp[x * 2][k], dp[x * 2 - 1][k] + dj[x]);
      dp[x * 2 - 1][k] = min(dp[x * 2 - 1][k], dp[x * 2][k] + dj[x]);
    }
  }
  for (int i = 0; i < xq[x].size(); i++) {
    if (ans[xq[x][i]]) continue;
    if (last[xq[x][i]] == cnum)
      curq.push_back(xq[x][i]);
    else
      last[xq[x][i]] = cnum;
  }
  for (int i = head[x]; i; i = table[i].nxt) {
    if (table[i].to != p && !vis[table[i].to]) dfs(table[i].to, x, table[i].id);
  }
  return;
}
void divid(int x, int f) {
  if (vis[x]) return;
  fa[x] = f;
  vis[x] = 1;
  for (int i = head[x]; i; i = table[i].nxt)
    if (!vis[table[i].to]) {
      sum = ::size[table[i].to];
      G = 0;
      getcen(table[i].to, x);
      divid(G, x);
    }
  cnum++;
  vis[x] = 0;
  curq.clear();
  dfs(x, 0, 0);
  for (int i = 0; i < curq.size(); i++) {
    int u = qq[curq[i]][0], v = qq[curq[i]][1];
    ans[curq[i]] = min(dp[u][0] + dp[v][0], dp[u][1] + dp[v][1]);
  }
}
void solve() {
  G = 0;
  f[0] = 1e9 + 9;
  sum = n;
  getcen(1, 0);
  divid(G, 0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ew[i + n][0];
  }
  for (int i = 1; i < n; i++) {
    long long x, y, w1, w2;
    cin >> x >> y >> w1 >> w2;
    ew[i][1] = w1;
    ew[i][0] = w2;
    Add(x, y, i);
    Add(y, x, i);
  }
  for (int i = 1; i <= n; i++) Add(0, i, i + n);
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> qq[i][0] >> qq[i][1];
    xq[(qq[i][0] + 1) / 2].push_back(i);
    xq[(qq[i][1] + 1) / 2].push_back(i);
  }
  init();
  solve();
  for (int i = 1; i <= q; i++) {
    cout << ans[i] << endl;
  }
}