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 = 300000 + 10;
const long long INF = 1LL << 60;
int n, h[maxn], ecnt, dep[maxn];
long long val[maxn];
struct enode {
  int v, n;
  long long w1, w2;
  enode() {}
  enode(int _v, int _n, long long _w1, long long _w2)
      : v(_v), n(_n), w1(_w1), w2(_w2) {}
} e[maxn << 1];
inline void addedge(int u, int v, long long w1, long long w2) {
  ecnt++;
  e[ecnt] = enode(v, h[u], w1, w2);
  h[u] = ecnt;
}
struct qnode {
  int u;
  long long w;
  qnode() {}
  qnode(int _u, long long _w) : u(_u), w(_w) {}
  friend bool operator<(qnode a, qnode b) { return a.w > b.w; }
};
inline void upmin(long long &x, long long y) { x = min(x, y); }
priority_queue<qnode> q;
long long d[maxn];
int vis[maxn];
inline void prepare() {
  while (!q.empty()) q.pop();
  int S = 0;
  d[S] = 0;
  for (int i = 1; i <= n; i++) {
    d[i] = val[i];
    q.push(qnode(i, d[i]));
  }
  while (!q.empty()) {
    qnode now = q.top();
    q.pop();
    int u = now.u;
    long long w = now.w;
    vis[u] = 1;
    if (d[u] < w) continue;
    for (int i = h[u]; ~i; i = e[i].n) {
      int v = e[i].v;
      if (vis[v]) continue;
      long long w = (long long)e[i].w1 + e[i].w2;
      if (d[v] > d[u] + w) {
        d[v] = d[u] + w;
        q.push(qnode(v, d[v]));
      }
    }
  }
}
long long dis[22][maxn][2][2];
int pre[22][maxn];
void dfs(int u, int fa) {
  dep[u] = dep[fa] + 1;
  for (int i = 1; i <= 20; i++) {
    pre[i][u] = pre[i - 1][pre[i - 1][u]];
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        dis[i][u][j][k] = INF;
        for (int l = 0; l < 2; l++) {
          upmin(dis[i][u][j][k],
                dis[i - 1][u][j][l] + dis[i - 1][pre[i - 1][u]][l][k]);
        }
      }
    }
  }
  for (int i = h[u]; ~i; i = e[i].n) {
    int v = e[i].v;
    if (v == fa) continue;
    pre[0][v] = u;
    dis[0][v][0][0] = min((long long)e[i].w1, (long long)d[u] + d[v] + e[i].w2);
    dis[0][v][1][1] = min((long long)e[i].w2, (long long)d[u] + d[v] + e[i].w1);
    dis[0][v][0][1] = min((long long)d[v] + e[i].w2, (long long)d[u] + e[i].w1);
    dis[0][v][1][0] = min((long long)d[v] + e[i].w1, (long long)d[u] + e[i].w2);
    dfs(v, u);
  }
}
inline int LCA(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int d = dep[u] - dep[v];
  for (int i = 0; i <= 20; i++)
    if (d & (1 << i)) u = pre[i][u];
  if (u == v) return u;
  for (int i = 20; i >= 0; i--)
    if (pre[i][u] != pre[i][v]) {
      u = pre[i][u];
      v = pre[i][v];
    }
  return pre[0][u];
}
inline pair<long long, long long> work(int u, int v, int k) {
  int D = dep[u] - dep[v];
  long long now[2];
  now[k] = 0;
  now[k ^ 1] = d[u];
  for (int i = 0; i <= 20; i++) {
    if (D & (1 << i)) {
      long long tmp[2] = {INF, INF};
      for (int j = 0; j < 2; j++) {
        upmin(tmp[j], now[j] + dis[i][u][j][j]);
        upmin(tmp[j], now[j ^ 1] + dis[i][u][j ^ 1][j]);
      }
      u = pre[i][u];
      now[0] = tmp[0];
      now[1] = tmp[1];
    }
  }
  return make_pair(now[0], now[1]);
}
int main() {
  scanf("%d", &n);
  ecnt = 0;
  memset(h, -1, sizeof(h));
  for (int i = 1; i <= n; i++) scanf("%I64d", &val[i]);
  for (int i = 1; i < n; i++) {
    int u, v;
    long long w1, w2;
    scanf("%d%d%I64d%I64d", &u, &v, &w1, &w2);
    addedge(u, v, w1, w2);
    addedge(v, u, w1, w2);
  }
  prepare();
  dfs(1, 0);
  int Q;
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    int x, y, u, v, ku, kv;
    scanf("%d%d", &x, &y);
    u = (x + 1) >> 1;
    v = (y + 1) >> 1;
    ku = (x + 1) & 1;
    kv = (y + 1) & 1;
    int lca = LCA(u, v);
    pair<long long, long long> t1 = work(u, lca, ku);
    pair<long long, long long> t2 = work(v, lca, kv);
    long long Ans = min(t1.first + t2.first, t1.second + t2.second);
    printf("%I64d\n", Ans);
  }
  return 0;
}