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;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
long long n, m, i, j, dis[300005], fa[300005][19], dep[300005], vis[300005], x,
    y, a, b;
vector<pair<long long, pair<long long, long long> > > e[300005];
priority_queue<pair<long long, long long> > pq;
struct lys {
  long long a[2][2];
  bool operator==(const lys &x) const {
    return a[0][0] == x.a[0][0] && a[0][1] == x.a[0][1] &&
           a[1][0] == x.a[1][0] && a[1][1] == x.a[1][1];
  }
} dp[300005][19], emt;
lys merge(lys x, lys y) {
  if (x == emt) return y;
  if (y == emt) return x;
  lys ans;
  ans.a[0][0] = min(x.a[0][0] + y.a[0][0], x.a[0][1] + y.a[1][0]);
  ans.a[0][1] = min(x.a[0][0] + y.a[0][1], x.a[0][1] + y.a[1][1]);
  ans.a[1][0] = min(x.a[1][0] + y.a[0][0], x.a[1][1] + y.a[1][0]);
  ans.a[1][1] = min(x.a[1][0] + y.a[0][1], x.a[1][1] + y.a[1][1]);
  return ans;
}
void dfs(long long x, long long p) {
  fa[x][0] = p;
  for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++) {
    if (it->first == p) continue;
    dep[it->first] = dep[x] + 1;
    dfs(it->first, x);
    dp[it->first][0].a[0][0] = it->second.first;
    dp[it->first][0].a[1][1] = it->second.second;
    dp[it->first][0].a[0][1] =
        min(it->second.first + dis[it->first], it->second.second + dis[x]);
    dp[it->first][0].a[1][0] =
        min(it->second.second + dis[it->first], it->second.first + dis[x]);
  }
}
long long solve(int x, int y, int a, int b) {
  lys sl = emt, sr = emt;
  int i;
  for ((i) = (18); (i) >= (0); (i)--)
    if (dep[fa[x][i]] >= dep[y]) {
      sl = merge(dp[x][i], sl);
      x = fa[x][i];
    }
  for ((i) = (18); (i) >= (0); (i)--)
    if (dep[fa[y][i]] >= dep[x]) {
      sr = merge(dp[y][i], sr);
      y = fa[y][i];
    }
  if (x == y)
    return min(min(sl.a[0][a] + sr.a[0][b], sl.a[1][a] + sr.a[1][b]),
               min(sl.a[0][a] + sr.a[1][b], sl.a[1][a] + sr.a[0][b]) + dis[x]);
  for ((i) = (18); (i) >= (0); (i)--)
    if (fa[x][i] != fa[y][i]) {
      sl = merge(dp[x][i], sl);
      sr = merge(dp[y][i], sr);
      x = fa[x][i];
      y = fa[y][i];
    }
  sl = merge(dp[x][0], sl);
  sr = merge(dp[y][0], sr);
  x = fa[x][0];
  return min(min(sl.a[0][a] + sr.a[0][b], sl.a[1][a] + sr.a[1][b]),
             min(sl.a[0][a] + sr.a[1][b], sl.a[1][a] + sr.a[0][b]) + dis[x]);
}
int main() {
  emt.a[0][0] = 0;
  emt.a[0][1] = 0x1bbbbbbbbbbbbbbbll;
  emt.a[1][0] = 0x1bbbbbbbbbbbbbbbll;
  emt.a[1][1] = 0;
  read(n);
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    read(dis[i]);
  }
  for (((i)) = (1); ((i)) <= ((n - 1)); ((i))++) {
    read(x);
    read(y);
    read(a);
    read(b);
    e[x].push_back(make_pair(y, make_pair(a, b)));
    e[y].push_back(make_pair(x, make_pair(a, b)));
  }
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) pq.push(make_pair(-dis[i], i));
  while (!pq.empty()) {
    x = pq.top().second;
    pq.pop();
    if (vis[x]) continue;
    vis[x] = 1;
    for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end();
         it++) {
      if (dis[it->first] > dis[x] + it->second.first + it->second.second) {
        dis[it->first] = dis[x] + it->second.first + it->second.second;
        pq.push(make_pair(-dis[it->first], it->first));
      }
    }
  }
  dep[1] = 1;
  dfs(1, 0);
  for (((j)) = (1); ((j)) <= ((18)); ((j))++)
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
      fa[i][j] = fa[fa[i][j - 1]][j - 1];
      if (fa[i][j]) dp[i][j] = merge(dp[fa[i][j - 1]][j - 1], dp[i][j - 1]);
    }
  read(m);
  while (m--) {
    read(x);
    read(y);
    printf("%I64d\n", solve((x + 1) / 2, (y + 1) / 2, !(x & 1), !(y & 1)));
  }
  return 0;
}