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 = 300005, MAXQ = 600005;
const long long INF = 0x3f3f3f3f3f3f3f3f;
struct edge {
  int to;
  long long w1, w2;
};
struct edge2 {
  int to;
  long long w;
};
struct query {
  int u, v, id;
};
vector<edge2> Gt[MAXN];
vector<edge> G[MAXN];
vector<query> qu[MAXN];
long long d[MAXN], dis[20][MAXN][2][2];
int dep[MAXN], maxbit, fa[20][MAXN];
void dfs(int u) {
  for (const auto &e : G[u]) {
    int v = e.to;
    if (v != fa[0][u]) {
      fa[0][v] = u;
      dep[v] = dep[u] + 1;
      dis[0][v][0][0] = e.w1;
      dis[0][v][1][1] = e.w2;
      dis[0][v][0][1] = min(e.w1 + d[u], e.w2 + d[v]);
      dis[0][v][1][0] = min(e.w2 + d[u], e.w1 + d[v]);
      dfs(v);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &d[i]);
  for (int i = 1; i < n; i++) {
    int u, v;
    long long w1, w2;
    scanf("%d%d%lld%lld", &u, &v, &w1, &w2);
    G[u].push_back({v, w1, w2});
    G[v].push_back({u, w1, w2});
    Gt[u].push_back({v, w1 + w2});
    Gt[v].push_back({u, w1 + w2});
  }
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      pq;
  for (int i = 1; i <= n; i++) pq.push(make_pair(d[i], i));
  while (!pq.empty()) {
    pair<long long, int> u = pq.top();
    pq.pop();
    if (d[u.second] != u.first) continue;
    for (const auto &e : Gt[u.second]) {
      int v = e.to;
      if (d[v] > u.first + e.w) {
        d[v] = u.first + e.w;
        pq.push(make_pair(d[v], v));
      }
    }
  }
  dep[1] = 1;
  dfs(1);
  while ((1 << maxbit) < n) maxbit++;
  maxbit--;
  for (int j = 1; j <= maxbit; j++)
    for (int i = 1; i <= n; i++) {
      fa[j][i] = fa[j - 1][fa[j - 1][i]];
      for (int k = 0; k < 2; k++)
        for (int l = 0; l < 2; l++)
          dis[j][i][k][l] =
              min(dis[j - 1][i][k][0] + dis[j - 1][fa[j - 1][i]][0][l],
                  dis[j - 1][i][k][1] + dis[j - 1][fa[j - 1][i]][1][l]);
    }
  int q;
  scanf("%d", &q);
  while (q--) {
    int u, v;
    scanf("%d%d", &u, &v);
    int p1 = (u % 2) ^ 1, p2 = (v % 2) ^ 1;
    u = (u + 1) / 2;
    v = (v + 1) / 2;
    if (dep[u] < dep[v]) {
      swap(u, v);
      swap(p1, p2);
    }
    long long dt[2][2], tmp[2];
    dt[0][p1] = 0;
    dt[0][p1 ^ 1] = d[u];
    dt[1][p2] = 0;
    dt[1][p2 ^ 1] = d[v];
    for (int i = maxbit; i >= 0; i--)
      if (dep[fa[i][u]] >= dep[v]) {
        memcpy(tmp, dt[0], sizeof(tmp));
        for (int j = 0; j < 2; j++)
          dt[0][j] =
              min(tmp[j] + dis[i][u][j][j], tmp[j ^ 1] + dis[i][u][j ^ 1][j]);
        u = fa[i][u];
      }
    if (u != v) {
      for (int i = maxbit; i >= 0; i--)
        if (fa[i][u] != fa[i][v]) {
          memcpy(tmp, dt[0], sizeof(tmp));
          for (int j = 0; j < 2; j++)
            dt[0][j] =
                min(tmp[j] + dis[i][u][j][j], tmp[j ^ 1] + dis[i][u][j ^ 1][j]);
          memcpy(tmp, dt[1], sizeof(tmp));
          for (int j = 0; j < 2; j++)
            dt[1][j] =
                min(tmp[j] + dis[i][v][j][j], tmp[j ^ 1] + dis[i][v][j ^ 1][j]);
          u = fa[i][u];
          v = fa[i][v];
        }
      memcpy(tmp, dt[0], sizeof(tmp));
      for (int j = 0; j < 2; j++)
        dt[0][j] =
            min(tmp[j] + dis[0][u][j][j], tmp[j ^ 1] + dis[0][u][j ^ 1][j]);
      memcpy(tmp, dt[1], sizeof(tmp));
      for (int j = 0; j < 2; j++)
        dt[1][j] =
            min(tmp[j] + dis[0][v][j][j], tmp[j ^ 1] + dis[0][v][j ^ 1][j]);
    }
    printf("%lld\n", min(dt[0][0] + dt[1][0], dt[0][1] + dt[1][1]));
  }
  return 0;
}