Problem: Nauuo is a girl who loves traveling.

One day she went to a tree, Old Driver Tree, literally, a tree with an old driver on it.

The tree is a connected graph consisting of n nodes and n-1 edges. Each node has a color, and Nauuo will visit the ODT through a simple path on the tree in the old driver's car.

Nauuo wants to visit see more different colors in her journey, but she doesn't know which simple path she will be traveling on. So, she wants to calculate the sum of the numbers of different colors on all different paths. Can you help her?

What's more, the ODT is being redecorated, so there will be m modifications, each modification will change a single node's color. Nauuo wants to know the answer after each modification too.

Note that in this problem, we consider the simple path from u to v and the simple path from v to u as two different simple paths if and only if u≠ v.

Input

The first line contains two integers n and m (2≤ n≤ 4⋅ 10^5, 1≤ m≤ 4⋅ 10^5) — the number of nodes and the number of modifications.

The second line contains n integers c_1,c_2,…,c_n (1≤ c_i≤ n), where c_i is the initial color of node i.

Each of the next n-1 lines contains two integers u and v (1≤ u,v≤ n), denoting there is an edge between u and v. It is guaranteed that the given edges form a tree.

Each of the next m lines contains two integers u and x (1≤ u,x≤ n), which means a modification that changes the color of node u into x.

Output

The output contains m+1 integers — the first integer is the answer at the beginning, the rest integers are the answers after every modification in the given order.

Examples

Input


5 3
1 2 1 2 3
1 2
1 3
3 4
3 5
3 3
4 1
4 3


Output


47
51
49
45


Input


6 1
1 1 1 1 1 1
1 2
2 3
3 4
4 5
5 6
1 2


Output


36
46

Note

Example 1

<image>

The number of colors on each simple path at the beginning:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int w = 0, x = 0;
  char c = getchar();
  while (!isdigit(c)) w |= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  return w ? -x : x;
}
namespace star {
const int maxn = 4e5 + 10;
int n, m, col[maxn], fa[maxn];
long long ans[maxn];
struct LCT {
  int son[maxn][2], fa[maxn], siz[maxn], siz2[maxn];
  long long Siz2[maxn];
  inline int getw(int x) { return son[fa[x]][1] == x; }
  inline bool notrt(int x) { return son[fa[x]][0] == x or son[fa[x]][1] == x; }
  inline void pushup(int x) {
    siz[x] = siz[son[x][0]] + siz[son[x][1]] + siz2[x] + 1;
  }
  inline void rotate(int x) {
    int y = fa[x], z = fa[y], w = getw(x), s = son[x][!w];
    if (notrt(y)) son[z][getw(y)] = x;
    son[y][w] = s, son[x][!w] = y;
    if (s) fa[s] = y;
    fa[y] = x;
    fa[x] = z;
    pushup(y);
  }
  inline void splay(int x) {
    while (notrt(x)) {
      int y = fa[x];
      if (notrt(y)) rotate(getw(x) ^ getw(y) ? x : y);
      rotate(x);
    }
    pushup(x);
  }
  inline void access(int x) {
    for (int y = 0; x; y = x, x = fa[x])
      splay(x), siz2[x] += siz[son[x][1]] - siz[y],
          Siz2[x] +=
          1ll * siz[son[x][1]] * siz[son[x][1]] - 1ll * siz[y] * siz[y],
          son[x][1] = y, pushup(x);
  }
  inline int findrt(int x) {
    access(x), splay(x);
    while (son[x][0]) x = son[x][0];
    splay(x);
    return x;
  }
  inline void link(int x) {
    splay(x);
    int y = fa[x] = star::fa[x];
    access(y), splay(y), siz2[y] += siz[x], Siz2[y] += 1ll * siz[x] * siz[x];
    pushup(x);
  }
  inline void cut(int x) {
    access(x), splay(x), son[x][0] = fa[son[x][0]] = 0, pushup(x);
  }
  inline void rev(int x) {
    col[x] ^= 1;
    if (col[x])
      cut(x);
    else
      link(x);
  }
  inline int query(int x) { return siz[son[findrt(x)][1]]; }
  inline long long query2(int x) { return access(x), Siz2[x]; }
} S;
struct operation {
  int x, op, t;
};
vector<operation> q[maxn];
int ecnt, head[maxn], to[maxn << 1], nxt[maxn << 1];
inline void addedge(int a, int b) {
  to[++ecnt] = b, nxt[ecnt] = head[a], head[a] = ecnt;
  to[++ecnt] = a, nxt[ecnt] = head[b], head[b] = ecnt;
}
void dfs(int x, int f) {
  fa[x] = f;
  S.link(x);
  for (int u, i = head[x]; i; i = nxt[i])
    if ((u = to[i]) != f) dfs(u, x);
}
inline void work() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++)
    q[col[i] = read()].push_back((operation){i, 1, 0});
  for (int i = 1; i < n; i++) addedge(read(), read());
  dfs(1, n + 1);
  for (int a, i = 1; i <= m; i++)
    a = read(), q[col[a]].push_back((operation){a, 0, i}),
    q[col[a] = read()].push_back((operation){a, 1, i});
  memset(col, 0, sizeof col);
  for (int i = 1; i <= n; i++) {
    long long sum = 0;
    for (auto &&x : q[i]) {
      ans[x.t] -= sum;
      if (x.op) {
        int zp = S.query(x.x);
        sum += 1ll * zp * zp;
        S.rev(x.x);
        zp = S.query(fa[x.x]);
        sum -= 1ll * zp * zp + S.query2(x.x);
      } else {
        int zp = S.query(fa[x.x]);
        sum += 1ll * zp * zp + S.query2(x.x);
        S.rev(x.x);
        zp = S.query(x.x);
        sum -= 1ll * zp * zp;
      }
      ans[x.t] += sum;
    }
    for (auto &&x : q[i]) S.rev(x.x);
  }
  for (int i = 1; i <= m; i++) ans[i] += ans[i - 1];
  for (int i = 0; i <= m; i++) printf("%lld\n", ans[i]);
}
}  // namespace star
signed main() {
  star::work();
  return 0;
}