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>
class Input {
 private:
  char buf[1000000], *p1, *p2;

 public:
  inline char getc() {
    if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
    return p1 == p2 ? EOF : *(p1++);
  }
  template <typename tp>
  inline Input& operator>>(tp& n) {
    n = 0;
    char c = getc();
    while (!isdigit(c)) c = getc();
    while (isdigit(c)) n = n * 10 + c - 48, c = getc();
    return (*this);
  }
} fin;
const int N = 4e5 + 5, M = 8e5 + 5;
using namespace std;
int n, m, num;
int head[N], nt[M], to[M];
int c[N], stk[M], dep[N], anc[N];
long long ans[N], Ans, Las;
struct Query {
  int x, t, tp;
  Query(int x = 0, int t = 0, int tp = 0) : x(x), t(t), tp(tp) {}
};
vector<Query> q[N];
void add(int, int);
void dfs(int, int);
namespace LCT {
int fa[N], c[N][2];
long long sz[N], sp[N], vir[N];
void init() {
  for (int i = 1; i <= n + 1; ++i) sz[i] = 1;
}
void clear(int x) {
  fa[x] = c[x][0] = c[x][1] = vir[x] = 0;
  sz[x] = 1;
}
bool nrt(int x) { return c[fa[x]][0] == x or c[fa[x]][1] == x; }
inline void update(int x) { sz[x] = sz[c[x][0]] + sz[c[x][1]] + vir[x] + 1; }
void rotate(int x) {
  int y = fa[x], z = fa[y], t = c[y][1] == x;
  if (z == x) exit(0);
  if (nrt(y)) c[z][c[z][1] == y] = x;
  fa[x] = z;
  c[y][t] = c[x][t ^ 1], fa[c[x][t ^ 1]] = y;
  c[x][t ^ 1] = y, fa[y] = x;
  update(y), update(x);
}
void splay(int x) {
  while (nrt(x)) {
    int y = fa[x], z = fa[y];
    if (nrt(y)) ((c[y][1] == x) ^ (c[z][1] == y)) ? rotate(x) : rotate(y);
    rotate(x);
  }
}
void access(int x) {
  for (int i = 0; x; x = fa[i = x])
    splay(x), vir[x] += sz[c[x][1]] - sz[i],
        sp[x] += sz[c[x][1]] * sz[c[x][1]] - sz[i] * sz[i], c[x][1] = i;
}
int findrt(int x) {
  access(x), splay(x);
  while (c[x][0]) x = c[x][0];
  splay(x);
  return x;
}
void link(int x, int y) {
  access(x), Ans -= sp[x];
  int z = findrt(y);
  access(x), splay(z);
  Ans -= sz[c[z][1]] * sz[c[z][1]];
  splay(x), splay(y);
  fa[x] = y, vir[y] += sz[x], sz[y] += sz[x], sp[y] += sz[x] * sz[x];
  access(x), splay(z);
  Ans += sz[c[z][1]] * sz[c[z][1]];
}
void cut(int x, int y) {
  access(x), Ans += sp[x];
  int z = findrt(x);
  access(x), splay(z);
  Ans -= sz[c[z][1]] * sz[c[z][1]];
  splay(x), c[x][0] = fa[c[x][0]] = 0, update(x);
  splay(z);
  Ans += sz[c[z][1]] * sz[c[z][1]];
}
}  // namespace LCT
int main() {
  fin >> n >> m;
  LCT::init();
  for (int i = 1; i <= n; ++i) fin >> c[i];
  for (int i = 1, a, b; i < n; ++i) fin >> a >> b, add(a, b);
  add(1, n + 1);
  dfs(n + 1, 0);
  for (int i = 1, x, u; i <= m; ++i) {
    fin >> x >> u;
    q[c[x]].push_back(Query(x, i, 0));
    q[c[x] = u].push_back(Query(x, i, 1));
  }
  for (int i = 1, top = 0; i <= n; ++i) {
    ans[0] += (Las = 1ll * n * n);
    for (auto now : q[i]) {
      int x = now.x, tim = now.t, tp = now.tp;
      if (tp == 0)
        LCT::link(x, anc[x]);
      else
        LCT::cut(x, anc[x]);
      ans[tim] += Ans - Las, Las = Ans;
    }
    for (int j = q[i].size() - 1; j >= 0; --j) {
      Query now = q[i][j];
      if (now.tp == 0)
        LCT::cut(now.x, anc[now.x]);
      else
        LCT::link(now.x, anc[now.x]);
    }
  }
  for (int i = 0; i <= m; ++i)
    cout << 1ll * n * n * n - ans[i] << endl, ans[i + 1] += ans[i];
  return 0;
}
void dfs(int p, int fa) {
  dep[p] = dep[fa] + 1;
  for (int i = head[p]; i; i = nt[i]) {
    int v = to[i];
    if (v == fa) continue;
    anc[v] = p, q[c[v]].push_back(Query(v, 0, 1));
    dfs(v, p);
    LCT::link(v, p);
  }
}
void add(int x, int y) {
  ++num, nt[num] = head[x], head[x] = num, to[num] = y;
  ++num, nt[num] = head[y], head[y] = num, to[num] = x;
}