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;
const int N = 1e6;
vector<int> cx[N], cy[N], cz[N];
int fa[N], fir[N], nxt[N], to[N], cnt = 0, n, m, col[N], ch[N][2], f[N], sz[N],
                                  sz1[N];
long long sz2[N], dt[N], ans = 0;
long long P(int a) { return 1ll * a * a; }
void add(int a, int b) {
  nxt[++cnt] = fir[a];
  to[cnt] = b;
  fir[a] = cnt;
}
void adda(int a, int b, int c, int d) {
  cx[a].push_back(b);
  cy[a].push_back(c);
  cz[a].push_back(d);
}
void DFS(int u) {
  for (int i = fir[u]; i; i = nxt[i])
    if (fa[u] != to[i]) fa[to[i]] = u, DFS(to[i]);
}
bool isrt(int x) { return (ch[f[x]][0] != x) & (ch[f[x]][1] != x); }
void pushup(int x) { sz[x] = sz1[x] + sz[ch[x][0]] + sz[ch[x][1]] + 1; }
bool son(int x) { return x == ch[f[x]][1]; }
void rotate(int x) {
  int a = f[x], b = f[a], c = son(x), d = son(a), e = ch[x][!c];
  if (!isrt(a)) ch[b][d] = x;
  ch[x][!c] = a;
  ch[a][c] = e;
  if (e) f[e] = a;
  f[a] = x;
  f[x] = b;
  pushup(a);
}
void splay(int x) {
  int b, c;
  while (!isrt(x)) {
    b = f[x];
    c = f[b];
    if (!isrt(b)) {
      if (son(b) == son(x))
        rotate(b);
      else
        rotate(x);
    }
    rotate(x);
  }
  pushup(x);
}
void access(int x) {
  for (int y = 0; x; y = x, x = f[x]) {
    splay(x);
    sz1[x] += sz[ch[x][1]] - sz[y];
    sz2[x] += P(sz[ch[x][1]]) - P(sz[y]);
    ch[x][1] = y;
    pushup(x);
  }
}
int getroot(int x) {
  access(x);
  splay(x);
  while (ch[x][0]) x = ch[x][0];
  splay(x);
  return x;
}
void link(int u) {
  int v = fa[u];
  splay(u);
  ans -= P(sz[ch[u][1]]);
  ans -= sz2[u];
  int w = getroot(v);
  access(u);
  splay(w);
  ans -= P(sz[ch[w][1]]);
  f[u] = v;
  splay(v);
  sz1[v] += sz[u];
  sz2[v] += P(sz[u]);
  pushup(v);
  access(u);
  splay(w);
  ans += P(sz[ch[w][1]]);
}
void cut(int u) {
  int v = fa[u];
  access(u);
  ans += sz2[u];
  int w = getroot(v);
  access(u);
  splay(w);
  ans -= P(sz[ch[w][1]]);
  splay(u);
  ch[u][0] = f[ch[u][0]] = 0;
  pushup(u);
  splay(w);
  ans += P(sz[ch[w][1]]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &col[i]), adda(col[i], i, 1, 0);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  for (int i = 1; i <= n + 1; i++) sz[i] = 1;
  fa[1] = n + 1;
  DFS(1);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    adda(col[x], x, -1, i);
    adda(col[x] = y, x, 1, i);
  }
  long long las = 1ll * n * n;
  for (int i = 1; i <= n; i++) link(i);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < cx[i].size(); j++) {
      int x = cx[i][j], y = cy[i][j], z = cz[i][j];
      if (y == -1)
        link(x);
      else
        cut(x);
      dt[z] -= ans - las;
      las = ans;
    }
    for (int j = cx[i].size() - 1; j >= 0; j--) {
      int x = cx[i][j], y = cy[i][j], z = cz[i][j];
      if (y == -1)
        cut(x);
      else
        link(x);
    }
    las = ans;
  }
  printf("%I64d\n", ans = dt[0]);
  for (int i = 1; i <= m; i++) printf("%I64d\n", ans += dt[i]);
  return 0;
}