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 N = 300000 + 10;
struct Edge {
  int v;
  long long w0, w1;
};
int n, sz[N], conquered[N], mx[N];
long long bridge[N];
vector<int> comp[N], compPath[N];
vector<Edge> g[N];
void dfs_miao(int id, int u, int p) {
  comp[id].push_back(u);
  sz[u] = 1;
  mx[u] = 0;
  for (auto e : g[u]) {
    if (e.v != p && conquered[e.v] == 0) {
      dfs_miao(id, e.v, u);
      sz[u] += sz[e.v];
      mx[u] = max(mx[u], sz[e.v]);
    }
  }
}
int getRoot(int id, int u) {
  dfs_miao(id, u, u);
  int mn = N, rt = -1;
  for (int i = 0; i < comp[id].size(); i++) {
    compPath[comp[id][i]].push_back(id);
    mx[comp[id][i]] = max(mx[comp[id][i]], sz[u] - sz[comp[id][i]]);
    if (mx[comp[id][i]] < mn) {
      mn = mx[comp[id][i]], rt = comp[id][i];
    }
  }
  return rt;
}
map<int, long long> dp[N][2];
void cacDP(int id, int u, int p) {
  for (auto e : g[u]) {
    if (e.v == p || conquered[e.v]) continue;
    int v = e.v;
    dp[id][0][v * 2 - 1] = dp[id][0][u * 2 - 1] + e.w0;
    dp[id][1][v * 2 - 1] = dp[id][1][u * 2 - 1] + e.w0;
    dp[id][0][v * 2] = dp[id][0][u * 2] + e.w1;
    dp[id][1][v * 2] = dp[id][1][u * 2] + e.w1;
    dp[id][0][v * 2 - 1] =
        min(dp[id][0][v * 2 - 1], dp[id][0][v * 2] + bridge[v]);
    dp[id][1][v * 2 - 1] =
        min(dp[id][1][v * 2 - 1], dp[id][1][v * 2] + bridge[v]);
    dp[id][0][v * 2] = min(dp[id][0][v * 2], dp[id][0][v * 2 - 1] + bridge[v]);
    dp[id][1][v * 2] = min(dp[id][1][v * 2], dp[id][1][v * 2 - 1] + bridge[v]);
    cacDP(id, e.v, u);
  }
}
int tot = 0;
void divide_and_conquere(int u) {
  int now = (++tot);
  u = getRoot(tot, u);
  conquered[u] = 1;
  dp[tot][1][u * 2 - 1] = dp[tot][0][u * 2] = bridge[u];
  cacDP(tot, u, u);
  for (auto e : g[u]) {
    if (!conquered[e.v]) {
      divide_and_conquere(e.v);
    }
  }
}
struct Nod {
  int id;
  long long dis;
  bool operator<(const Nod& o) const { return dis > o.dis; }
};
struct Dijkstra {
  vector<pair<int, long long> > gragh[N];
  long long dis[N];
  void dijkstra() {
    for (int i = 1; i <= n; i++) {
      gragh[0].push_back(make_pair(i, bridge[i]));
    }
    for (int i = 1; i <= n; i++) {
      for (auto e : g[i]) {
        gragh[i].push_back(make_pair(e.v, e.w0 + e.w1));
      }
    }
    priority_queue<Nod> q;
    memset(dis, -1, sizeof(dis));
    q.push((Nod){0, 0});
    dis[0] = 0;
    while (q.size()) {
      Nod tmp = q.top();
      q.pop();
      if (dis[tmp.id] != -1 && dis[tmp.id] < tmp.dis) continue;
      for (int i = 0; i < gragh[tmp.id].size(); i++) {
        int v = gragh[tmp.id][i].first;
        if (dis[v] == -1 || dis[tmp.id] + gragh[tmp.id][i].second < dis[v]) {
          dis[v] = dis[tmp.id] + gragh[tmp.id][i].second;
          q.push((Nod){v, dis[v]});
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      bridge[i] = dis[i];
    }
  }
} saber;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &bridge[i]);
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    long long w0, w1;
    scanf("%d%d%lld%lld", &u, &v, &w0, &w1);
    g[u].push_back((Edge){v, w0, w1});
    g[v].push_back((Edge){u, w0, w1});
  }
  saber.dijkstra();
  divide_and_conquere(1);
  int q;
  scanf("%d", &q);
  while (q--) {
    int u, v;
    scanf("%d%d", &u, &v);
    int lef = 0,
        rig = min(compPath[(u + 1) / 2].size(), compPath[(v + 1) / 2].size());
    while (rig - lef > 1) {
      int mid = (lef + rig) >> 1;
      if (compPath[(u + 1) / 2][mid] == compPath[(v + 1) / 2][mid])
        lef = mid;
      else
        rig = mid;
    }
    int id = compPath[(u + 1) / 2][lef];
    long long ans =
        min(dp[id][0][u] + dp[id][0][v], dp[id][1][u] + dp[id][1][v]);
    printf("%lld\n", ans);
  }
}