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;
struct E {
  int v;
  long long w1, w2;
  E* next;
};
long long add(long long x, long long y) {
  return x != -1 && y != -1 ? (x + y) : -1;
}
long long cmp(long long x, long long y) {
  return x != -1 && (x < y || y == -1);
}
struct Mat {
  long long g[2][2];
  Mat() { memset(g, -1, sizeof(g)); }
  Mat(initializer_list<long long> list) {
    const long long* ptr = list.begin();
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j) g[i][j] = *ptr++;
  }
  const long long* operator[](int k) const { return g[k]; }
  long long* operator[](int k) { return g[k]; }
  Mat operator*(const Mat& rhs) const {
    Mat ret = Mat();
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j)
        for (int k = 0; k < 2; ++k)
          ret[i][j] = min(ret[i][j], add(g[i][k], rhs[k][j]), cmp);
    return ret;
  }
};
const int N = 300010, Q = 600010;
int n;
long long wn[N], ans[Q];
int f[N], qu[Q][2];
Mat val[N];
vector<pair<int, bool>> qry[N];
vector<int> q2[N];
bool vis[N], opt[Q][2];
E* g[N];
void adde(int u, int v, long long w1, long long w2) {
  static E pool[N * 2], *p = pool;
  p->v = v;
  p->w1 = w1;
  p->w2 = w2;
  p->next = g[u];
  g[u] = p++;
}
void dfs1(int u);
void dfs2(int u);
Mat tran(const Mat& m) { return {m[0][0], m[1][0], m[0][1], m[1][1]}; }
int find(int x) {
  if (f[x] == x) return x;
  int prt = f[x];
  f[x] = find(f[x]);
  val[x] = val[x] * val[prt];
  return f[x];
}
void dfs3(int u);
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld", &wn[i]);
  for (int rep = 1; rep < n; ++rep) {
    int u, v;
    long long w1, w2;
    scanf("%d%d%lld%lld", &u, &v, &w1, &w2);
    adde(u, v, w1, w2);
    adde(v, u, w1, w2);
  }
  dfs1(1);
  memset(vis, 0, sizeof(vis));
  dfs2(1);
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    int u = (x + 1) >> 1, v = (y + 1) >> 1;
    bool a = !(x & 1), b = !(y & 1);
    qu[i][0] = u;
    qu[i][1] = v;
    opt[i][0] = a;
    opt[i][1] = b;
    qry[u].emplace_back(i, 0);
    qry[v].emplace_back(i, 1);
  }
  fill(val + 1, val + n + 1, Mat{0, -1, -1, 0});
  dfs3(1);
  for (int i = 1; i <= q; ++i) printf("%lld\n", ans[i]);
  return 0;
}
void dfs1(int u) {
  vis[u] = true;
  for (E* p = g[u]; p; p = p->next)
    if (!vis[p->v]) dfs1(p->v), wn[u] = min(wn[u], wn[p->v] + p->w1 + p->w2);
}
void dfs2(int u) {
  vis[u] = true;
  for (E* p = g[u]; p; p = p->next)
    if (!vis[p->v]) wn[p->v] = min(wn[p->v], wn[u] + p->w1 + p->w2), dfs2(p->v);
}
void dfs3(int u) {
  f[u] = u;
  for (E* p = g[u]; p; p = p->next)
    if (!f[p->v]) {
      dfs3(p->v);
      f[p->v] = u;
      val[p->v] = Mat({0, wn[p->v], wn[p->v], 0}) * Mat({p->w1, -1, -1, p->w2});
    }
  for (const auto& q : qry[u])
    if (f[qu[q.first][!q.second]]) {
      int lca = find(qu[q.first][!q.second]);
      q2[lca].push_back(q.first);
    }
  Mat cur{0, wn[u], wn[u], 0};
  for (int id : q2[u]) {
    Mat res1 = (find(qu[id][0]), val[qu[id][0]]),
        res2 = (find(qu[id][1]), val[qu[id][1]]);
    ans[id] = (res1 * cur * tran(res2))[opt[id][0]][opt[id][1]];
  }
}