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 gi() {
  int data = 0, fu = 1;
  char ch = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') fu = -1, ch = getchar();
  while ('0' <= ch && ch <= '9')
    data = (data << 1) + (data << 3) + (ch ^ 48), ch = getchar();
  return data * fu;
}
int ch[2][400005], fa[400005], Fa[400005], sz[400005], xz[400005], col[400005],
    n, m;
vector<int> edge[400005];
bool Del[400005];
long long sum[400005], ans[400005], Ans;
bool cht;
vector<pair<int, int> > Act[400005];
inline void DeBug() {
  for (int i = 1; i <= n; ++i)
    printf("Node%d: fa=%d, lson=%d, rson=%d, sz=%d, xz=%d, sum=%lld\n", i,
           fa[i], ch[0][i], ch[1][i], sz[i], xz[i], sum[i]);
  return cout << "================================================"
              << " ; ans[0]=" << ans[0] << endl,
         void();
}
inline long long Sqr(int x) { return 1ll * x * x; }
inline bool Son(int x) { return ch[1][fa[x]] == x; }
inline bool Isroot(int x) { return ch[0][fa[x]] != x && ch[1][fa[x]] != x; }
inline void PushUp(int x) { sz[x] = sz[ch[1][x]] + sz[ch[0][x]] + xz[x] + 1; }
inline void Rot(int x) {
  int y = fa[x], z = fa[y], c = Son(x);
  if (!Isroot(y)) ch[Son(y)][z] = x;
  fa[x] = z;
  fa[ch[c][y] = ch[!c][x]] = y;
  fa[ch[!c][x] = y] = x;
  PushUp(y);
}
inline void Splay(int x) {
  for (int y = fa[x]; !Isroot(x); Rot(x), y = fa[x])
    if (!Isroot(y)) Son(x) ^ Son(y) ? Rot(x) : Rot(y);
  PushUp(x);
}
inline void Access(int x) {
  for (int y = 0, z; x; y = x, x = fa[x]) {
    Splay(x);
    z = ch[1][x];
    if (y) sum[x] -= 1ll * sz[y] * sz[y], xz[x] -= sz[y];
    if (z) sum[x] += 1ll * sz[z] * sz[z], xz[x] += sz[z];
    ch[1][x] = y;
    PushUp(x);
  }
  return;
}
inline int Size(int x) {
  Access(x);
  if (cht) DeBug();
  Splay(x);
  while (ch[0][x]) x = ch[0][x];
  Splay(x);
  return sz[ch[1][x]];
}
inline long long Link(int x, int f) {
  Del[x] = false;
  long long ret = 0;
  if (!Del[f]) ret -= Sqr(Size(f));
  Splay(x);
  ret -= sum[x] + Sqr(sz[ch[1][x]]);
  Splay(f);
  fa[x] = f;
  xz[f] += sz[x];
  sum[f] += 1ll * sz[x] * sz[x];
  PushUp(f);
  ret += Sqr(Size(x));
  return ret;
}
inline long long Cut(int x, int f) {
  Del[x] = true;
  long long ret = 0;
  ret = -Sqr(Size(x));
  Splay(x);
  Splay(f);
  ch[1][f] = fa[x] = 0;
  PushUp(f);
  if (!Del[f]) ret += Sqr(Size(f));
  ret += sum[x];
  return ret;
}
void dfs(int u, int From) {
  sz[u] = 1;
  Fa[u] = From;
  for (auto v : edge[u])
    if (v != From) dfs(v, u);
  if (From) Link(u, From);
  return;
}
int main() {
  n = gi();
  m = gi();
  for (int i = 1, c; i <= n; ++i)
    c = gi(), Act[c].push_back(make_pair(0, -i)), col[i] = c;
  for (int i = 1, u, v; i < n; ++i)
    u = gi(), v = gi(), edge[u].push_back(v), edge[v].push_back(u);
  edge[++n].push_back(1);
  dfs(n, 0);
  for (int i = 1, u, x; i <= m; ++i) {
    u = gi(), x = gi();
    Act[col[u]].push_back(make_pair(i, u));
    col[u] = x;
    Act[col[u]].push_back(make_pair(i, -u));
  }
  int u;
  for (int c = 1; c < n; ++c) {
    ans[0] += 1ll * (n - 1) * (n - 1);
    for (auto upd : Act[c]) {
      u = upd.second;
      if (u < 0)
        u = -u, ans[upd.first] += Cut(u, Fa[u]);
      else
        ans[upd.first] += Link(u, Fa[u]);
      u = abs(u);
    }
    cht = false;
    for (auto upd : Act[c]) {
      u = abs(upd.second);
      if (Del[u]) Link(u, Fa[u]);
    }
  }
  Ans = 0;
  --n;
  for (int t = 0; t <= m; ++t)
    Ans += ans[t], printf("%lld\n", 1ll * n * n * n - Ans);
  return 0;
}