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>
void pr1(int *a, int n) {
  for (int i = 1; i <= n; ++i) printf("%d ", a[i]);
  puts("");
}
void pr0(int *a, int n) {
  for (int i = 0; i <= n; ++i) printf("%d ", a[i]);
  puts("");
}
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  x *= f;
}
int n;
vector<int> e[600010];
vector<long long> w[600010];
vector<int> et[300010];
void jb(int x, int y, long long ww) {
  e[x].push_back(y);
  e[y].push_back(x);
  w[x].push_back(ww);
  w[y].push_back(ww);
}
inline int oth(int x) { return x + ((x & 1) ? 1 : (-1)); }
inline int bl(int x) { return (x + 1) >> 1; }
vector<int> hv[600010];
int xx[600010], yy[600010];
long long ans[600010];
int hs[600010], vis[300010];
int sz[300010];
void dfs1(int x, int fa) {
  int si = et[x].size();
  sz[x] = 1;
  for (int i = 0; i < si; ++i) {
    int u = et[x][i];
    if (u != fa && (!vis[u])) dfs1(u, x), sz[x] += sz[u];
  }
}
int rt, rts;
void gtrt(int x, int fa) {
  int si = et[x].size();
  int msz = 0;
  for (int i = 0; i < si; ++i) {
    int u = et[x][i];
    if (!vis[u]) msz = max(msz, sz[u]);
    if (u != fa && (!vis[u])) {
      sz[x] = sz[x] - sz[u];
      sz[u] += sz[x];
      gtrt(u, x);
      sz[u] = sz[u] - sz[x];
      sz[x] += sz[u];
    }
  }
  if (msz < rts) rt = x, rts = msz;
}
long long dis1[600010], dis2[600010];
int ppd1[600010], ppd2[600010];
int cl1[600010], cln1, cl2[600010], cln2;
struct ha {
  int x;
  long long d;
};
bool operator<(const ha &a, const ha &b) { return a.d > b.d; }
priority_queue<ha> hp;
void dij(int s, long long *dis, int *cl, int *ppd, int &cln) {
  while (cln) ppd[cl[cln]] = 0, dis[cl[cln]] = (0x1f1f1f1f1f1f1f1f), --cln;
  dis[s] = 0;
  hp.push((ha){s, 0});
  while (!hp.empty()) {
    int x = hp.top().x;
    hp.pop();
    if (ppd[x]) continue;
    ppd[x] = 1;
    cl[++cln] = x;
    int si = e[x].size();
    for (int i = 0; i < si; ++i) {
      int u = e[x][i];
      long long tp = dis[x] + w[x][i];
      if ((dis[u] > tp) && (!vis[bl(u)])) dis[u] = tp, hp.push((ha){u, dis[u]});
    }
  }
}
void solve(int x, int fa) {
  dfs1(x, 0);
  rt = 0;
  rts = 1e9;
  gtrt(x, 0);
  x = rt;
  int si = et[x].size();
  vis[x] = 1;
  for (int i = 0; i < si; ++i) {
    int u = et[x][i];
    if (!vis[u]) solve(u, x);
  }
  vis[x] = 0;
  dij(x * 2 - 1, dis1, cl1, ppd1, cln1);
  dij(x * 2, dis2, cl2, ppd2, cln2);
  si = hv[x].size();
  for (int i = 0; i < si; ++i) {
    int id = hv[x][i];
    hv[fa].push_back(id);
    ans[id] = min(ans[id], dis1[xx[id]] + dis2[yy[id]] + dis1[x * 2]);
    ans[id] = min(ans[id], dis2[xx[id]] + dis1[yy[id]] + dis1[x * 2]);
    ans[id] = min(ans[id], dis1[xx[id]] + dis1[yy[id]]);
    ans[id] = min(ans[id], dis2[xx[id]] + dis2[yy[id]]);
  }
}
int main() {
  read(n);
  memset(dis1, 0x1f, sizeof(dis1));
  memset(dis2, 0x1f, sizeof(dis2));
  memset(ans, 0x1f, sizeof(ans));
  for (int i = 1; i <= n; ++i) {
    long long ww;
    read(ww);
    jb(2 * i - 1, 2 * i, ww);
  }
  for (int i = 1; i < n; ++i) {
    int x, y;
    long long w1, w2;
    read(x);
    read(y);
    read(w1);
    read(w2);
    et[x].push_back(y);
    et[y].push_back(x);
    jb(2 * x - 1, 2 * y - 1, w1);
    jb(2 * x, 2 * y, w2);
  }
  int q;
  read(q);
  for (int i = 1; i <= q; ++i) {
    int x, y;
    read(x);
    read(y);
    xx[i] = x;
    yy[i] = y;
    hv[bl(x)].push_back(i);
  }
  solve(1, 0);
  for (int i = 1; i <= q; ++i) printf("%lld\n", ans[i]);
  return 0;
}