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;
#pragma warning(disable : 4996)
struct E {
  int to;
  vector<long long> w;
};
const long long INF = 1e18;
const int N = 3e5 + 5, L = 20;
vector<E> g[N];
long long t[N], d[2][2][N][L];
int anc[N][L], tin[N], tout[N];
int timer = 0, n;
void deep(int node) {
  for (E e : g[node]) {
    if (e.to != anc[node][0]) {
      anc[e.to][0] = node;
      deep(e.to);
      t[node] = min(t[node], t[e.to] + e.w[0] + e.w[1]);
    }
  }
}
void walk(int node, long long u) {
  u = min(u, t[node]);
  t[node] = u;
  for (E e : g[node]) {
    if (e.to != anc[node][0]) walk(e.to, u + e.w[0] + e.w[1]);
  }
}
void dfs(int node) {
  tin[node] = timer++;
  for (int i = 1; i < L; i++) {
    anc[node][i] = anc[anc[node][i - 1]][i - 1];
    for (int x = 0; x < 2; x++) {
      for (int y = 0; y < 2; y++) {
        for (int z = 0; z < 2; z++) {
          d[x][z][node][i] =
              min(d[x][z][node][i],
                  d[x][y][node][i - 1] + d[y][z][anc[node][i - 1]][i - 1]);
        }
      }
    }
  }
  for (E e : g[node]) {
    if (e.to != anc[node][0]) {
      anc[e.to][0] = node;
      for (int i = 0; i < 2; i++) {
        d[i][i][e.to][0] = min(e.w[i], e.w[1 - i] + t[node] + t[e.to]);
        d[i][1 - i][e.to][0] = min(e.w[1 - i] + t[e.to], t[node] + e.w[i]);
      }
      dfs(e.to);
    }
  }
  tout[node] = timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
long long calc(int x, int a, int y, int b) {
  long long dp[2];
  dp[x] = 0;
  dp[1 - x] = t[a];
  if (a == b) return dp[y];
  for (int i = L - 1; i >= 0; i--) {
    if (!upper(anc[a][i], b)) {
      long long ndp[2] = {INF, INF};
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          ndp[k] = min(ndp[k], dp[j] + d[j][k][a][i]);
        }
      }
      for (int j = 0; j < 2; j++) dp[j] = ndp[j];
      a = anc[a][i];
    }
  }
  return min(dp[0] + d[0][y][a][0], dp[1] + d[1][y][a][0]);
}
int getLca(int a, int b) {
  if (upper(a, b)) return a;
  for (int i = L - 1; i >= 0; i--) {
    if (!upper(anc[a][i], b)) a = anc[a][i];
  }
  return anc[a][0];
}
long long getAns(int a, int b) {
  int x = a % 2, y = b % 2;
  a /= 2;
  b /= 2;
  int l = getLca(a, b);
  long long ans = min(calc(x, a, 0, l) + calc(y, b, 0, l),
                      calc(x, a, 1, l) + calc(y, b, 1, l));
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    long long w1, w2;
    cin >> x >> y >> w1 >> w2;
    x--, y--;
    g[x].push_back({y, {w1, w2}});
    g[y].push_back({x, {w1, w2}});
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < n; k++) {
        for (int h = 0; h < L; h++) {
          d[i][j][k][h] = INF;
        }
      }
    }
  }
  deep(0);
  walk(0, INF);
  dfs(0);
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    cout << getAns(a, b) << "\n";
  }
  return 0;
}