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 = 300005;
int n, Q;
long long ans[N * 2];
bool vis[N * 2];
struct edgeG {
  int to, next;
  long long w;
};
struct G {
  edgeG e[N * 6];
  int head[N * 2], tot;
  void add(int x, int y, long long v) {
    e[++tot] = (edgeG){y, head[x], v};
    head[x] = tot;
    e[++tot] = (edgeG){x, head[y], v};
    head[y] = tot;
  }
  priority_queue<pair<long long, long long> > Q;
  void SSSP(int S, long long *dis) {
    for (; !Q.empty(); Q.pop())
      ;
    dis[S] = 0;
    Q.push(pair<long long, long long>(0, S));
    while (!Q.empty()) {
      pair<long long, long long> tmp = Q.top();
      Q.pop();
      if (-tmp.first != dis[tmp.second]) continue;
      for (int i = head[tmp.second]; i; i = e[i].next)
        if (!vis[e[i].to] && dis[e[i].to] > dis[tmp.second] + e[i].w) {
          dis[e[i].to] = dis[tmp.second] + e[i].w;
          Q.push(pair<long long, long long>(-dis[e[i].to], e[i].to));
        }
    }
  }
} G;
struct edgeT {
  int to, next;
};
struct query {
  int bx, by, x, y, id;
};
struct Tree {
  edgeT e[N * 2];
  int head[N], tot;
  vector<query> vec[N];
  void add(int x, int y) {
    e[++tot] = (edgeT){y, head[x]};
    head[x] = tot;
    e[++tot] = (edgeT){x, head[y]};
    head[y] = tot;
  }
  void addQ(int bx, int by, int x, int y, int id) {
    vec[bx].push_back((query){bx, by, x, y, id});
  }
  int sz[N], co[N];
  int mxv, mxrt;
  long long d0[N * 2], d1[N * 2];
  void dfs(int x, int fa, int n) {
    sz[x] = 1;
    int mx = 0;
    co[x] = *co;
    d0[x * 2] = d1[x * 2] = d0[x * 2 - 1] = d1[x * 2 - 1] = 1ll << 60;
    for (int i = head[x]; i; i = e[i].next)
      if (e[i].to != fa && !vis[e[i].to * 2]) {
        dfs(e[i].to, x, n);
        sz[x] += sz[e[i].to];
        mx = max(mx, sz[e[i].to]);
      }
    mx = max(mx, n - sz[x]);
    if (mx < mxv) mxv = mx, mxrt = x;
  }
  void getans(int x, int fa) {
    for (int i = (int)(0); i <= (int)(vec[x].size() - 1); i++) {
      query q = vec[x][i];
      if (co[q.bx] == co[q.by]) {
        ans[q.id] = min(ans[q.id], d0[q.x] + d0[q.y]);
        ans[q.id] = min(ans[q.id], d1[q.x] + d1[q.y]);
      }
    }
    for (int i = head[x]; i; i = e[i].next)
      if (e[i].to != fa && !vis[e[i].to * 2]) getans(e[i].to, x);
  }
  void solve(int x, int n) {
    mxv = 1 << 30;
    ++*co;
    dfs(x, 0, n);
    x = mxrt;
    G.SSSP(x * 2, d0);
    G.SSSP(x * 2 - 1, d1);
    vis[x * 2] = vis[x * 2 - 1] = 1;
    getans(x, 0);
    for (int i = head[x]; i; i = e[i].next)
      if (!vis[e[i].to * 2])
        solve(e[i].to, sz[x] > sz[e[i].to] ? sz[e[i].to] : n - sz[x]);
  }
} T;
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); i++) {
    long long w;
    scanf("%lld", &w);
    G.add(i * 2 - 1, i * 2, w);
  }
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    int x, y;
    long long w1, w2;
    scanf("%d%d%lld%lld", &x, &y, &w1, &w2);
    G.add(x * 2 - 1, y * 2 - 1, w1);
    G.add(x * 2, y * 2, w2);
    T.add(x, y);
  }
  scanf("%d", &Q);
  for (int i = (int)(1); i <= (int)(Q); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int bex = (x + 1) / 2;
    int bey = (y + 1) / 2;
    T.addQ(bex, bey, x, y, i);
    ans[i] = 1ll << 60;
  }
  T.solve(1, n);
  for (int i = (int)(1); i <= (int)(Q); i++) printf("%lld\n", ans[i]);
}