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>
int n, m, col[400010];
long long ans, res[400010];
namespace Qtree6 {
namespace LCT {
int sz[400010], sz2[400010], f[400010], s[400010][2];
long long size2[400010];
inline void pushup(int const &x) {
  sz[x] = 1 + sz[s[x][0]] + sz[s[x][1]] + sz2[x];
}
inline bool isroot(int const &x) { return s[f[x]][0] != x && s[f[x]][1] != x; }
inline void rotate(int const &x) {
  int y = f[x], z = f[y], k = s[y][1] == x;
  if (!isroot(y)) s[z][s[z][1] == y] = x;
  f[x] = z, f[y] = x, f[s[x][k ^ 1]] = y, s[y][k] = s[x][k ^ 1],
  s[x][k ^ 1] = y, pushup(y), pushup(x);
}
inline void splay(int const &x) {
  while (!isroot(x)) {
    if (!isroot(f[x]))
      rotate((s[f[x]][0] == x) ^ (s[f[f[x]]][0] == f[x]) ? x : f[x]);
    rotate(x);
  }
  pushup(x);
}
inline void access(int x) {
  for (int y = 0; x; y = x, x = f[x])
    splay(x), sz2[x] += sz[s[x][1]] - sz[y],
        size2[x] += 1ll * sz[s[x][1]] * sz[s[x][1]] - 1ll * sz[y] * sz[y],
        s[x][1] = y, pushup(x);
}
inline int findroot(int x) {
  access(x), splay(x);
  while (s[x][0]) x = s[x][0];
  splay(x);
  return x;
}
inline void cut(int const &x, int const &y) {
  access(y), splay(x), s[x][1] = f[y] = 0, pushup(x);
}
inline void link(int const &x, int const &y) {
  splay(x), f[x] = y, access(y), splay(y), sz2[y] += sz[x],
            size2[y] += 1ll * sz[x] * sz[x], pushup(x);
}
}  // namespace LCT
std::vector<int> v[400010];
int book[400010], f[400010];
void dfs(int const &x, int const &fa) {
  book[x] = 1, f[x] = fa;
  for (auto const &to : v[x])
    if (to != fa) dfs(to, x);
}
inline void init() {
  for (int i = 1, x, y; i < n; i++)
    scanf("%d%d", &x, &y), v[x].push_back(y), v[y].push_back(x);
  v[n + 1].push_back(1), dfs(n + 1, 0);
  for (int i = 1; i <= n; i++) LCT::link(i, f[i]);
}
inline void rev(int const &u) {
  if (book[u])
    LCT::cut(f[u], u);
  else
    LCT::link(u, f[u]);
  book[u] ^= 1;
}
inline int query(int const &u) {
  int op = LCT::findroot(u);
  return LCT::sz[op] - LCT::sz2[op] - 1;
}
inline long long query2(int const &u) {
  LCT::access(u);
  return LCT::size2[u];
}
}  // namespace Qtree6
std::vector<std::tuple<int, int, int>> q[400010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    scanf("%d", col + i), q[col[i]].emplace_back(i, 1, 0);
  Qtree6::init();
  for (int i = 1, a, b; i <= m; i++) {
    scanf("%d%d", &a, &b);
    q[col[a]].emplace_back(a, 0, i);
    q[col[a] = b].emplace_back(a, 1, i);
  }
  int v, c, t, p, d;
  long long e;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    for (auto &&tp : q[i]) {
      std::tie(v, c, t) = tp;
      res[t] -= ans;
      if (c == 1) {
        p = Qtree6::query(v);
        ans += 1ll * p * p;
        Qtree6::rev(v);
        d = Qtree6::query(Qtree6::f[v]);
        e = Qtree6::query2(v);
        ans -= 1ll * d * d + e;
      } else {
        p = Qtree6::query(Qtree6::f[v]);
        e = Qtree6::query2(v);
        ans += 1ll * p * p + e;
        Qtree6::rev(v);
        d = Qtree6::query(v);
        ans -= 1ll * d * d;
      }
      res[t] += ans;
    }
    for (auto &&tp : q[i]) Qtree6::rev(std::get<0>(tp));
  }
  for (int i = 1; i <= m; i++) res[i] += res[i - 1];
  for (int i = 0; i <= m; i++) printf("%lld\n", res[i]);
  return 0;
}