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 = 4e5 + 6;
int n, m, head[N], cnt, fa[N], dep[N], c[N];
long long ans[N], Num;
bool col[N];
vector<unsigned long long> E[N];
namespace lct {
int ch[N][2], fa[N], sz[N], sm[N], _v[N];
long long szz[N];
bool tag[N];
inline bool ckr(int x, int p = 1) { return ch[fa[x]][p] == x; }
inline bool isroot(int x) { return !(ckr(x) || ckr(x, 0)); }
inline long long calc(int x) { return (long long)sm[x] * sm[x]; }
inline void update(int x) {
  sz[x] = sz[ch[x][0]] + sz[ch[x][1]] + 1;
  sm[x] = sm[ch[x][0]] + sm[ch[x][1]] + _v[x] + 1;
}
inline void flip(int x) { swap(ch[x][0], ch[x][1]), tag[x] ^= 1; }
inline void pushdown(int x) {
  if (tag[x]) {
    if (ch[x][0]) flip(ch[x][0]);
    if (ch[x][1]) flip(ch[x][1]);
    tag[x] = 0;
  }
}
void rotate(int x) {
  int y = fa[x], z = fa[y], k = ckr(x);
  if (!isroot(y)) ch[z][ckr(y)] = x;
  fa[x] = z, fa[y] = x, fa[ch[x][!k]] = y;
  ch[y][k] = ch[x][!k], ch[x][!k] = y;
  update(y);
}
void splay(int x) {
  static int sta[N], top;
  sta[top = 1] = x;
  for (int y = x; !isroot(y); sta[++top] = y = fa[y])
    ;
  while (top) pushdown(sta[top--]);
  for (; !isroot(x); rotate(x))
    if (!isroot(fa[x])) rotate((ckr(x) ^ ckr(fa[x])) ? x : fa[x]);
  update(x);
}
void access(int x) {
  for (int t = 0; x; ch[x][1] = t, t = x, x = fa[x]) {
    splay(x);
    _v[x] -= sm[t], _v[x] += sm[ch[x][1]];
    szz[x] -= calc(t), szz[x] += calc(ch[x][1]);
  }
}
void makeroot(int x) { access(x), splay(x), flip(x); }
int findroot(int x) {
  access(x);
  for (splay(x); ch[x][0]; x = ch[x][0])
    ;
  splay(x);
  return x;
}
void link(int x, int y) {
  splay(x);
  Num -= szz[x] + calc(ch[x][1]);
  access(y), splay(y);
  int z = findroot(y);
  splay(z);
  Num -= calc(ch[z][1]);
  splay(y), fa[x] = y;
  _v[y] += sm[x], szz[y] += calc(x), update(y);
  access(x), splay(z);
  Num += calc(ch[z][1]);
}
void cut(int x, int y) {
  access(x);
  Num += szz[x];
  int z = findroot(x);
  splay(z);
  Num -= calc(ch[z][1]);
  splay(y), ch[y][1] = fa[x] = 0, update(y);
  access(y), splay(z);
  Num += calc(ch[z][1]);
}
}  // namespace lct
struct edge {
  int to, nxt;
} e[N << 1];
void dfs(int now, int pre) {
  for (int i = head[now]; i; i = e[i].nxt)
    if (e[i].to != pre) fa[e[i].to] = now, dfs(e[i].to, now);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> c[i], E[c[i]].push_back(i);
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    e[++cnt] = (edge){v, head[u]}, head[u] = cnt;
    e[++cnt] = (edge){u, head[v]}, head[v] = cnt;
  }
  dfs(1, 0);
  for (int i = 1; i <= m; ++i) {
    int u, x;
    cin >> u >> x;
    E[c[u]].push_back((unsigned long long)i << 32 | u);
    c[u] = x;
    E[x].push_back((unsigned long long)i << 32 | u);
  }
  fa[1] = n + 1;
  for (int i = 1; i <= n + 1; ++i) lct::sm[i] = lct::sz[i] = 1;
  for (int i = 1; i <= n; ++i) lct::link(i, fa[i]);
  for (int i = 1; i <= n; ++i) {
    long long dlt = 0;
    for (unsigned long long t : E[i]) {
      int tm = t >> 32, u = (int)t;
      if (col[u])
        lct::link(u, fa[u]);
      else
        lct::cut(u, fa[u]);
      col[u] ^= 1;
      ans[tm] += (long long)n * n - Num - dlt;
      dlt = (long long)n * n - Num;
    }
    for (int u : E[i])
      if (col[u]) col[u] = 0, lct::link(u, fa[u]);
  }
  for (int i = 0; i <= m; ++i) cout << (ans[i] += i ? ans[i - 1] : 0) << '\n';
  return 0;
}