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 void read(int &x) {
  char ch;
  int flg = 1;
  while (!isdigit(ch = getchar()))
    if (ch == '-') flg = -flg;
  for (x = ch - '0'; isdigit(ch = getchar()); x = x * 10 + ch - '0')
    ;
  x *= flg;
}
const int MAXN = 400005;
int n, m, c[MAXN], fir[MAXN], to[MAXN << 1], nxt[MAXN << 1], cnt, pa[MAXN];
inline void link(int u, int v) {
  to[++cnt] = v;
  nxt[cnt] = fir[u];
  fir[u] = cnt;
}
int ch[MAXN][2], fa[MAXN];
int sz[MAXN], szi[MAXN];
long long szi2[MAXN], ans;
inline bool isr(int x) { return x != ch[fa[x]][0] && x != ch[fa[x]][1]; }
inline bool get(int x) { return x == ch[fa[x]][1]; }
inline void upd(int x) { sz[x] = szi[x] + sz[ch[x][0]] + sz[ch[x][1]] + 1; }
inline void rot(int x) {
  int y = fa[x], z = fa[y];
  bool o = get(x);
  if (!isr(y)) ch[z][get(y)] = x;
  fa[x] = z;
  fa[ch[y][o] = ch[x][o ^ 1]] = y;
  fa[ch[x][o ^ 1] = y] = x;
  upd(y), upd(x);
}
inline void splay(int x) {
  for (; !isr(x); rot(x))
    if (!isr(fa[x])) rot(get(fa[x]) == get(x) ? fa[x] : x);
}
inline long long sqr(long long x) { return x * x; }
inline void access(int x) {
  for (int y = 0; x; x = fa[y = x]) {
    splay(x);
    szi[x] += sz[ch[x][1]];
    szi[x] -= sz[y];
    szi2[x] += sqr(sz[ch[x][1]]);
    szi2[x] -= sqr(sz[y]);
    ch[x][1] = y;
    upd(x);
  }
}
int findrt(int x) {
  access(x);
  splay(x);
  while (ch[x][0]) x = ch[x][0];
  return x;
}
inline void Link(int x) {
  int y = pa[x], z = findrt(y);
  access(y), splay(z);
  ans -= sqr(sz[ch[z][1]]);
  access(x);
  ans -= szi2[x];
  fa[x] = y;
  splay(y);
  szi2[y] += sqr(sz[x]);
  szi[y] += sz[x];
  upd(y);
  access(x), splay(z);
  ans += sqr(sz[ch[z][1]]);
}
inline void Cut(int x) {
  int y = pa[x], z = findrt(y);
  access(x), splay(z);
  ans -= sqr(sz[ch[z][1]]);
  ans += szi2[x];
  splay(y);
  ch[y][1] = 0;
  fa[x] = 0;
  upd(y);
  splay(z);
  ans += sqr(sz[ch[z][1]]);
}
void dfs(int u, int ff) {
  pa[u] = ff;
  for (int i = fir[u], v; i; i = nxt[i])
    if ((v = to[i]) != ff) dfs(v, u);
}
vector<pair<int, int> > vec[MAXN];
long long cf[MAXN];
bool vis[MAXN];
int main() {
  read(n), read(m);
  for (int i = 1; i <= n; ++i) read(c[i]);
  for (int i = 1, u, v; i < n; ++i) read(u), read(v), link(u, v), link(v, u);
  dfs(1, 0);
  pa[1] = n + 1;
  for (int i = 1; i <= n; ++i) vec[c[i]].push_back(pair<int, int>(0, i));
  for (int i = 1, x, y; i <= m; ++i) {
    read(x), read(y);
    vec[c[x]].push_back(pair<int, int>(i, x));
    vec[c[x] = y].push_back(pair<int, int>(i, x));
  }
  for (int i = 1; i <= n; ++i) sz[i] = 1, Link(i);
  for (int i = 1; i <= n; ++i) {
    cf[0] += 1ll * n * n;
    long long pre = 1ll * n * n;
    for (int j = 0, k, siz = vec[i].size(); j < siz; j = k) {
      for (k = j; k < siz && vec[i][j].first == vec[i][k].first; ++k)
        ;
      for (int l = j; l < k; ++l) {
        vis[vec[i][l].second] ? Link(vec[i][l].second) : Cut(vec[i][l].second);
        vis[vec[i][l].second] ^= 1;
      }
      cf[vec[i][j].first] += ans - pre;
      pre = ans;
    }
    for (int j = 0, siz = vec[i].size(); j < siz; ++j)
      if (vis[vec[i][j].second])
        vis[vec[i][j].second] = 0, Link(vec[i][j].second);
  }
  for (int i = 0; i <= m; ++i) {
    if (i) cf[i] += cf[i - 1];
    printf("%lld\n", 1ll * n * n * n - cf[i]);
  }
}