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;
int n, q, par[300005][19], d[300005];
long long to[300005][19][2][2], at[2][2], bt[2][2], ct[2][2];
long long w[300005];
vector<pair<int, pair<long long, long long>>> v[300005];
priority_queue<pair<long long, int>, vector<pair<long long, int>>,
               greater<pair<long long, int>>>
    qq;
int ta, tb, aa, bb;
long long tc, td;
void merge(long long a[2][2], long long b[2][2], long long c[2][2]) {
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      c[i][j] = min(a[i][0] + b[0][j], a[i][1] + b[1][j]);
}
void dfs(int a) {
  for (int i = 1; i < 19; i++) {
    merge(to[a][i - 1], to[par[a][i - 1]][i - 1], to[a][i]);
    par[a][i] = par[par[a][i - 1]][i - 1];
  }
  for (auto& i : v[a])
    if (i.first != par[a][0]) {
      par[i.first][0] = a;
      d[i.first] = d[a] + 1;
      to[i.first][0][0][0] =
          min(i.second.first, w[a] + w[i.first] + i.second.second);
      to[i.first][0][1][1] =
          min(i.second.second, w[a] + w[i.first] + i.second.first);
      to[i.first][0][0][1] =
          min(i.second.first + w[a], w[i.first] + i.second.second);
      to[i.first][0][1][0] =
          min(i.second.second + w[a], w[i.first] + i.second.first);
      dfs(i.first);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", w + i);
    qq.emplace(w[i], i);
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d%lld%lld", &ta, &tb, &tc, &td);
    v[ta].emplace_back(tb, make_pair(tc, td));
    v[tb].emplace_back(ta, make_pair(tc, td));
  }
  while (!qq.empty()) {
    tie(tc, ta) = qq.top();
    qq.pop();
    if (w[ta] != tc) continue;
    for (auto& i : v[ta]) {
      long long nd = w[ta] + i.second.first + i.second.second;
      if (nd < w[i.first]) {
        w[i.first] = nd;
        qq.emplace(nd, i.first);
      }
    }
  }
  dfs(1);
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &ta, &tb);
    if (ta % 2)
      ta = (ta + 1) / 2, aa = 0;
    else
      ta /= 2, aa = 1;
    if (tb % 2)
      tb = (tb + 1) / 2, bb = 0;
    else
      tb /= 2, bb = 1;
    memset(at, 0, sizeof(at));
    memset(bt, 0, sizeof(bt));
    if (d[ta] > d[tb]) {
      swap(ta, tb);
      swap(aa, bb);
    }
    at[0][1] = at[1][0] = w[ta];
    bt[0][1] = bt[1][0] = w[tb];
    for (int i = 0; i < 19; i++)
      if ((d[tb] - d[ta]) & (1 << i)) {
        merge(bt, to[tb][i], ct);
        memcpy(bt, ct, sizeof(bt));
        tb = par[tb][i];
      }
    if (ta != tb) {
      for (int i = 18; i >= 0; i--)
        if (par[ta][i] != par[tb][i]) {
          merge(at, to[ta][i], ct);
          memcpy(at, ct, sizeof(at));
          merge(bt, to[tb][i], ct);
          memcpy(bt, ct, sizeof(bt));
          ta = par[ta][i];
          tb = par[tb][i];
        }
      {
        int i = 0;
        merge(at, to[ta][i], ct);
        memcpy(at, ct, sizeof(at));
        merge(bt, to[tb][i], ct);
        memcpy(bt, ct, sizeof(bt));
        ta = par[ta][i];
        tb = par[tb][i];
      }
    }
    printf("%lld\n", min(at[aa][0] + bt[bb][0], at[aa][1] + bt[bb][1]));
  }
}