#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  bool f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    f |= ch == '-';
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  x = f ? -x : x;
}
template <typename T>
inline void print(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const long long N = 3e5 + 3;
long long head[N], to[N << 1], Next[N << 1], edge[N << 1], tot = 1, n, a[N], q;
inline void Addedge(long long u, long long v, long long w) {
  to[++tot] = v, edge[tot] = w, Next[tot] = head[u], head[u] = tot;
  return;
}
long long fa[N], siz[N], son[N], dep[N], up[N], down[N];
inline void Dfs1(long long x, long long f) {
  dep[x] = dep[f] + 1, siz[x] = 1, fa[x] = f;
  for (register long long i = head[x]; i; i = Next[i]) {
    long long y = to[i];
    if (y == f) continue;
    down[y] = down[x] + edge[i], up[y] = up[x] + edge[i ^ 1];
    Dfs1(y, x);
    siz[x] += siz[y];
    son[x] = siz[son[x]] < siz[y] ? y : son[x];
  }
  return;
}
long long top[N];
void Dfs2(long long x) {
  top[x] = son[fa[x]] == x ? top[fa[x]] : x;
  if (son[x]) Dfs2(son[x]);
  for (long long i = head[x]; i; i = Next[i]) {
    long long y = to[i];
    if (y == fa[x] || y == son[x]) continue;
    Dfs2(y);
  }
  return;
}
long long LCA(long long u, long long v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] > dep[top[v]])
      u = fa[top[u]];
    else
      v = fa[top[v]];
  }
  return dep[u] > dep[v] ? v : u;
}
long long dp[N][2];
inline long long Get(long long v, long long i) {
  return dp[v][0] - edge[i] - edge[i ^ 1];
}
long long g[N];
void Dfs(long long x) {
  dp[x][0] = a[x];
  for (long long i = head[x]; i; i = Next[i]) {
    long long y = to[i];
    if (y == fa[x]) continue;
    Dfs(y);
    if (Get(y, i) > 0) dp[x][0] += Get(y, i);
  }
}
void Croot(long long x) {
  for (long long i = head[x]; i; i = Next[i]) {
    long long y = to[i];
    if (y == fa[x]) continue;
    long long tmp = 0;
    if (Get(y, i) > 0) tmp = Get(y, i);
    if (dp[x][1] - tmp - edge[i] - edge[i ^ 1] > 0)
      dp[y][1] = dp[y][0] + dp[x][1] - tmp - edge[i] - edge[i ^ 1];
    else
      dp[y][1] = dp[y][0];
    g[y] = g[x] + dp[y][0] - tmp;
    Croot(y);
  }
}
signed main() {
  read(n), read(q);
  for (long long i = 1; i <= n; ++i) read(a[i]);
  for (long long i = 1; i < n; ++i) {
    long long x, y, z;
    read(x), read(y), read(z);
    Addedge(x, y, z), Addedge(y, x, z);
  }
  Dfs1(1, 0), Dfs2(1);
  Dfs(1);
  dp[1][1] = dp[1][0];
  Croot(1);
  while (q--) {
    long long u, v;
    read(u), read(v);
    long long l = LCA(u, v);
    long long ans1 = up[u] - up[l] + down[v] - down[l],
              ans2 = g[u] + g[v] - 2 * g[l] + dp[l][1];
    print(ans2 - ans1), puts("");
  }
  return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

You are given a weighted tree (undirected connected graph with no cycles, loops or multiple edges) with n vertices. The edge \\{u_j, v_j\} has weight w_j. Also each vertex i has its own value a_i assigned to it.

Let's call a path starting in vertex u and ending in vertex v, where each edge can appear no more than twice (regardless of direction), a 2-path. Vertices can appear in the 2-path multiple times (even start and end vertices).

For some 2-path p profit Pr(p) = ∑_{v ∈ distinct vertices in  p}{a_v} - ∑_{e ∈ distinct edges in  p}{k_e ⋅ w_e}, where k_e is the number of times edge e appears in p. That is, vertices are counted once, but edges are counted the number of times they appear in p.

You are about to answer m queries. Each query is a pair of vertices (qu, qv). For each query find 2-path p from qu to qv with maximal profit Pr(p).

Input

The first line contains two integers n and q (2 ≤ n ≤ 3 ⋅ 10^5, 1 ≤ q ≤ 4 ⋅ 10^5) — the number of vertices in the tree and the number of queries.

The second line contains n space-separated integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the values of the vertices.

Next n - 1 lines contain descriptions of edges: each line contains three space separated integers u_i, v_i and w_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i, 1 ≤ w_i ≤ 10^9) — there is edge \\{u_i, v_i\} with weight w_i in the tree.

Next q lines contain queries (one per line). Each query contains two integers qu_i and qv_i (1 ≤ qu_i, qv_i ≤ n) — endpoints of the 2-path you need to find.

Output

For each query print one integer per line — maximal profit Pr(p) of the some 2-path p with the corresponding endpoints.

Example

Input

7 6
6 5 5 3 2 1 2
1 2 2
2 3 2
2 4 1
4 5 1
6 4 2
7 3 25
1 1
4 4
5 6
6 4
3 4
3 7


Output

9
9
9
8
12
-14

Note

Explanation of queries: 

  1. (1, 1) — one of the optimal 2-paths is the following: 1 → 2 → 4 → 5 → 4 → 2 → 3 → 2 → 1. Pr(p) = (a_1 + a_2 + a_3 + a_4 + a_5) - (2 ⋅ w(1,2) + 2 ⋅ w(2,3) + 2 ⋅ w(2,4) + 2 ⋅ w(4,5)) = 21 - 2 ⋅ 12 = 9. 
  2. (4, 4): 4 → 2 → 1 → 2 → 3 → 2 → 4. Pr(p) = (a_1 + a_2 + a_3 + a_4) - 2 ⋅ (w(1,2) + w(2,3) + w(2,4)) = 19 - 2 ⋅ 10 = 9. 
  3. (5, 6): 5 → 4 → 2 → 3 → 2 → 1 → 2 → 4 → 6. 
  4. (6, 4): 6 → 4 → 2 → 1 → 2 → 3 → 2 → 4. 
  5. (3, 4): 3 → 2 → 1 → 2 → 4. 
  6. (3, 7): 3 → 2 → 1 → 2 → 4 → 5 → 4 → 2 → 3 → 7. 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  bool f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    f |= ch == '-';
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  x = f ? -x : x;
}
template <typename T>
inline void print(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const long long N = 3e5 + 3;
long long head[N], to[N << 1], Next[N << 1], edge[N << 1], tot = 1, n, a[N], q;
inline void Addedge(long long u, long long v, long long w) {
  to[++tot] = v, edge[tot] = w, Next[tot] = head[u], head[u] = tot;
  return;
}
long long fa[N], siz[N], son[N], dep[N], up[N], down[N];
inline void Dfs1(long long x, long long f) {
  dep[x] = dep[f] + 1, siz[x] = 1, fa[x] = f;
  for (register long long i = head[x]; i; i = Next[i]) {
    long long y = to[i];
    if (y == f) continue;
    down[y] = down[x] + edge[i], up[y] = up[x] + edge[i ^ 1];
    Dfs1(y, x);
    siz[x] += siz[y];
    son[x] = siz[son[x]] < siz[y] ? y : son[x];
  }
  return;
}
long long top[N];
void Dfs2(long long x) {
  top[x] = son[fa[x]] == x ? top[fa[x]] : x;
  if (son[x]) Dfs2(son[x]);
  for (long long i = head[x]; i; i = Next[i]) {
    long long y = to[i];
    if (y == fa[x] || y == son[x]) continue;
    Dfs2(y);
  }
  return;
}
long long LCA(long long u, long long v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] > dep[top[v]])
      u = fa[top[u]];
    else
      v = fa[top[v]];
  }
  return dep[u] > dep[v] ? v : u;
}
long long dp[N][2];
inline long long Get(long long v, long long i) {
  return dp[v][0] - edge[i] - edge[i ^ 1];
}
long long g[N];
void Dfs(long long x) {
  dp[x][0] = a[x];
  for (long long i = head[x]; i; i = Next[i]) {
    long long y = to[i];
    if (y == fa[x]) continue;
    Dfs(y);
    if (Get(y, i) > 0) dp[x][0] += Get(y, i);
  }
}
void Croot(long long x) {
  for (long long i = head[x]; i; i = Next[i]) {
    long long y = to[i];
    if (y == fa[x]) continue;
    long long tmp = 0;
    if (Get(y, i) > 0) tmp = Get(y, i);
    if (dp[x][1] - tmp - edge[i] - edge[i ^ 1] > 0)
      dp[y][1] = dp[y][0] + dp[x][1] - tmp - edge[i] - edge[i ^ 1];
    else
      dp[y][1] = dp[y][0];
    g[y] = g[x] + dp[y][0] - tmp;
    Croot(y);
  }
}
signed main() {
  read(n), read(q);
  for (long long i = 1; i <= n; ++i) read(a[i]);
  for (long long i = 1; i < n; ++i) {
    long long x, y, z;
    read(x), read(y), read(z);
    Addedge(x, y, z), Addedge(y, x, z);
  }
  Dfs1(1, 0), Dfs2(1);
  Dfs(1);
  dp[1][1] = dp[1][0];
  Croot(1);
  while (q--) {
    long long u, v;
    read(u), read(v);
    long long l = LCA(u, v);
    long long ans1 = up[u] - up[l] + down[v] - down[l],
              ans2 = g[u] + g[v] - 2 * g[l] + dp[l][1];
    print(ans2 - ans1), puts("");
  }
  return 0;
}

```