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;
void solve(std::istream &in, std::ostream &out);
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  solve(std::cin, std::cout);
  return 0;
}
struct edge_t {
  int to;
  array<int64_t, 2> w;
  edge_t(int to, array<int64_t, 2> w) : to(to), w(w) {}
};
void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  vector<int64_t> d(n);
  for (int64_t &i : d) {
    in >> i;
  }
  vector<vector<edge_t>> graph(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    in >> u >> v;
    --u, --v;
    int64_t w1, w2;
    in >> w1 >> w2;
    graph[u].emplace_back(v, array<int64_t, 2>{w1, w2});
    graph[v].emplace_back(u, array<int64_t, 2>{w1, w2});
  }
  int q;
  in >> q;
  vector<pair<int, int>> qs(q);
  vector<int64_t> ans(q, -1);
  for (auto &[u, v] : qs) {
    in >> u >> v;
    --u, --v;
  }
  {
    vector<int> Q(n);
    vector<int> p(n, -1);
    int qs = 0, qe = 0;
    Q[qe++] = 0;
    while (qs < qe) {
      int u = Q[qs++];
      for (auto &[v, w] : graph[u]) {
        if (v != p[u]) {
          Q[qe++] = v;
          p[v] = u;
        }
      }
    }
    for (int i = n - 1; i >= 0; --i) {
      int u = Q[i];
      for (auto &[v, w] : graph[u]) {
        if (v != p[v]) {
          d[u] = min(d[u], d[v] + w[0] + w[1]);
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      int u = Q[i];
      for (auto &[v, w] : graph[u]) {
        if (v != p[v]) {
          d[v] = min(d[v], d[u] + w[0] + w[1]);
        }
      }
    }
  }
  vector<int> level(n, -1);
  vector<int> parent(n, -1);
  function<void(int, int, int, int)> build = [&](int v, int size, int depth,
                                                 int last) {
    function<int(int, int, int &, int)> dfs = [&](int v, int size, int &center,
                                                  int p) {
      int sum = 1;
      for (auto &[x, w] : graph[v])
        if (level[x] == -1 && x != p) sum += dfs(x, size, center, v);
      if (center == -1 && (2 * sum >= size || p == -1)) center = v;
      return sum;
    };
    int center = -1;
    dfs(v, size, center, -1);
    level[center] = depth;
    parent[center] = last;
    for (auto &[x, w] : graph[center])
      if (level[x] == -1) build(x, size / 2, depth + 1, center);
  };
  function<int(int, int)> get_center = [&](int a, int b) {
    while (level[a] > level[b]) a = parent[a];
    while (level[a] < level[b]) b = parent[b];
    while (a != b) a = parent[a], b = parent[b];
    return a;
  };
  build(0, n, 0, -1);
  vector<vector<int>> qqs(n);
  for (int i = 0; i < q; ++i) {
    int u = qs[i].first;
    int v = qs[i].second;
    qqs[get_center(u / 2, v / 2)].push_back(i);
  }
  vector<array<int64_t, 2>> dp(2 * n, array<int64_t, 2>{});
  function<void(int)> process_centroid = [&](int root) {
    static vector<bool> vis(n, false);
    fill(vis.begin(), vis.end(), false);
    function<void(int, int, array<int64_t, 2>)> collect_subtree =
        [&](int v, int p, array<int64_t, 2> e) {
          if (v != root) {
            for (int k = 0; k < 2; ++k) {
              int64_t &d1 = dp[2 * v][k];
              int64_t &d2 = dp[2 * v + 1][k];
              d1 = dp[2 * p][k] + e[0];
              d2 = dp[2 * p + 1][k] + e[1];
              d1 = min(d1, d2 + d[v]);
              d2 = min(d2, d1 + d[v]);
            }
          }
          vis[v] = true;
          for (auto &[u, w] : graph[v]) {
            if (u != p && level[u] > level[root]) {
              collect_subtree(u, v, w);
            }
          }
        };
    vis[root] = true;
    dp[2 * root][0] = dp[2 * root + 1][1] = 0;
    dp[2 * root][1] = dp[2 * root + 1][0] = d[root];
    for (auto &[v, w] : graph[root]) {
      if (level[v] > level[root]) {
        collect_subtree(v, root, w);
      }
    }
    for (int i : qqs[root]) {
      int u = qs[i].first;
      int v = qs[i].second;
      ans[i] = min(dp[u][0] + dp[v][0], dp[u][1] + dp[v][1]);
    }
  };
  for (int i = 0; i < n; ++i) {
    process_centroid(i);
  }
  for (int64_t a : ans) {
    out << a << '\n';
  }
}