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;
struct pat {
  int x, y;
  pat(int x = 0, int y = 0) : x(x), y(y) {}
  bool operator<(const pat &p) const { return x == p.x ? y < p.y : x < p.x; }
};
template <typename TP>
inline void read(TP &tar) {
  TP ret = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    ret = ret * 10 + (ch - '0');
    ch = getchar();
  }
  tar = ret * f;
}
namespace RKK {
const int N = 400011;
struct sumireko {
  int to, ne;
} e[N << 1];
int he[N], ecnt;
void addline(int f, int t) {
  e[++ecnt].to = t;
  e[ecnt].ne = he[f], he[f] = ecnt;
}
int n, qaq, c[N];
long long ans;
vector<pat> opt[N];
int f[N];
void dfs(int x) {
  for (int i = he[x], t = e[i].to; i; i = e[i].ne, t = e[i].to)
    if (t != f[x]) f[t] = x, dfs(t);
}
int son[N][2], fa[N], size[N];
int os[N];
long long os2[N];
void fuckup(int x) { size[x] = 1 + size[son[x][0]] + size[son[x][1]] + os[x]; }
int isroot(int x) { return son[fa[x]][0] != x && son[fa[x]][1] != x; }
void rot(int x) {
  int y = fa[x], z = fa[y], xis = son[y][1] == x, yis = son[z][1] == y;
  if (!isroot(y)) son[z][yis] = x;
  fa[x] = z, fa[y] = x, fa[son[x][xis ^ 1]] = y;
  son[y][xis] = son[x][xis ^ 1], son[x][xis ^ 1] = y;
  fuckup(y), fuckup(x);
}
void splay(int x) {
  while (!isroot(x)) {
    int y = fa[x], z = fa[y], xis = son[y][1] == x, yis = son[z][1] == y;
    if (!isroot(y)) rot(xis ^ yis ? x : y);
    rot(x);
  }
}
void access(int x) {
  int lst = 0;
  while (x) {
    splay(x);
    os[x] += size[son[x][1]] - size[lst];
    os2[x] +=
        1ll * size[son[x][1]] * size[son[x][1]] - 1ll * size[lst] * size[lst];
    son[x][1] = lst, lst = x, x = fa[x];
  }
}
int findroot(int x) {
  access(x), splay(x);
  while (son[x][0]) x = son[x][0];
  splay(x);
  return x;
}
void link(int x, int y = 0) {
  y = f[x];
  splay(x);
  ans -= os2[x] + 1ll * size[son[x][1]] * size[son[x][1]];
  int z = findroot(y);
  access(x), splay(z);
  ans -= 1ll * size[son[z][1]] * size[son[z][1]];
  fa[x] = y;
  splay(y);
  os[y] += size[x], os2[y] += 1ll * size[x] * size[x];
  fuckup(y), access(x), splay(z);
  ans += 1ll * size[son[z][1]] * size[son[z][1]];
}
void cut(int x, int y = 0) {
  y = f[x];
  access(x);
  ans += os2[x];
  int z = findroot(y);
  access(x), splay(z);
  ans -= 1ll * size[son[z][1]] * size[son[z][1]];
  splay(x), son[x][0] = fa[son[x][0]] = 0;
  fuckup(x), splay(z);
  ans += 1ll * size[son[z][1]] * size[son[z][1]];
}
long long del[N];
bool bw[N];
int main() {
  read(n), read(qaq);
  for (int i = 1; i <= n + 1; i++) size[i] = 1;
  for (int i = 1; i <= n; i++) read(c[i]), opt[c[i]].push_back(pat(i, 0));
  for (int i = 2, x, y; i <= n; i++)
    read(x), read(y), addline(x, y), addline(y, x);
  for (int i = 1, x, v; i <= qaq; i++)
    read(x), read(v), opt[c[x]].push_back(pat(x, i)),
        opt[v].push_back(pat(x, i)), c[x] = v;
  f[1] = n + 1, dfs(1);
  for (int i = 1; i <= n; i++) link(i);
  long long last = 0;
  for (int i = 1; i <= n; i++) {
    if (!opt[i].size()) {
      del[0] += 1ll * n * n;
      continue;
    }
    if (opt[i][0].y) {
      del[0] += 1ll * n * n;
      last = 1ll * n * n;
    } else
      last = 0;
    for (int j = 0, x; j <= opt[i].size() - 1; j++) {
      x = opt[i][j].x;
      bw[x] ? link(x) : cut(x);
      bw[x] ^= 1;
      if (j == opt[i].size() - 1 || opt[i][j].y != opt[i][j + 1].y)
        del[opt[i][j].y] += ans - last, last = ans;
    }
    for (int j = opt[i].size() - 1, x; j >= 0; j--) {
      x = opt[i][j].x;
      bw[x] ? link(x) : cut(x);
      bw[x] ^= 1;
    }
  }
  long long prt = 1ll * n * n * n;
  for (int rkk = 0; rkk <= qaq; rkk++) prt -= del[rkk], printf("%lld\n", prt);
  return 0;
}
}  // namespace RKK
int main() { return RKK::main(); }