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;
int read() {
  int X = 0;
  char ch = 0;
  while (ch < 48 || ch > 57) ch = getchar();
  while (ch >= 48 && ch <= 57) X = X * 10 + (ch ^ 48), ch = getchar();
  return X;
}
struct Node {
  int l, r, f, c, pc;
  long long pc2;
  bool col;
  inline void add(int tc) {
    pc += tc;
    pc2 += 1ll * tc * tc;
  }
  inline void del(int tc) {
    pc -= tc;
    pc2 -= 1ll * tc * tc;
  }
} a[400500];
inline void up(int u) { a[u].c = a[a[u].l].c + a[a[u].r].c + a[u].pc + 1; }
inline bool nrt(int u) { return a[a[u].f].l == u || a[a[u].f].r == u; }
inline void rot(int u) {
  int fa = a[u].f, gf = a[fa].f;
  if (a[gf].l == fa) a[gf].l = u;
  if (a[gf].r == fa) a[gf].r = u;
  a[a[fa].f = u].f = gf;
  if (a[fa].l == u) {
    a[a[fa].l = a[u].r].f = fa;
    a[u].r = fa;
  } else {
    a[a[fa].r = a[u].l].f = fa;
    a[u].l = fa;
  }
  up(fa);
  up(u);
}
void splay(int u) {
  while (nrt(u)) {
    int fa = a[u].f, gf = a[fa].f;
    if (nrt(fa) && (a[fa].l == u) == (a[gf].l == fa)) rot(fa);
    rot(u);
  }
}
void access(int x) {
  for (int y = 0; x; x = a[y = x].f) {
    splay(x);
    a[x].add(a[a[x].r].c);
    a[x].del(a[y].c);
    a[x].r = y;
    up(x);
  }
}
int findrt(int x) {
  access(x);
  splay(x);
  while (a[x].l) x = a[x].l;
  splay(x);
  return x;
}
void link(int x, int y) {
  splay(x);
  access(y);
  splay(y);
  a[a[x].f = y].add(a[x].c);
  up(y);
}
void cut(int x, int y) {
  access(x);
  splay(y);
  a[x].f = a[y].r = 0;
  up(y);
}
int qry(int u) {
  int rt = findrt(u);
  splay(rt);
  return a[rt].c - a[rt].pc - 1;
}
int fa[400500];
long long rev(int u) {
  long long ret = 0;
  if (a[u].col) {
    int c = qry(u);
    ret -= 1ll * c * c;
    cut(u, fa[u]);
    access(u);
    c = qry(fa[u]);
    ret += a[u].pc2 + 1ll * c * c;
  } else {
    access(u);
    int c = qry(fa[u]);
    ret -= a[u].pc2 + 1ll * c * c;
    link(u, fa[u]);
    c = qry(u);
    ret += 1ll * c * c;
  }
  a[u].col ^= 1;
  return ret;
}
vector<int> g[400500];
void adl(int f, int t) {
  g[f].push_back(t);
  g[t].push_back(f);
}
void pfs(int u, int _fa) {
  fa[u] = _fa;
  a[u].col = a[u].c = 1;
  link(u, _fa);
  for (int i = 0; i < g[u].size(); i++)
    if (g[u][i] != _fa) pfs(g[u][i], u);
}
long long ans[400500];
struct Data {
  int u, p;
};
vector<Data> b[400500];
void solve(vector<Data> &b) {
  for (int i = 0; i < b.size(); i++) ans[b[i].p] += rev(b[i].u);
  for (int i = 0; i < b.size(); i++)
    if (!a[b[i].u].col) rev(b[i].u);
}
int n, m, col[400500];
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) b[col[i] = read()].push_back((Data){i, 0});
  for (int i = 1, f, t; i < n; i++) {
    f = read();
    t = read();
    adl(f, t);
  }
  adl(1, n + 1);
  pfs(1, n + 1);
  long long buf = ans[0] = 1ll * n * n * n;
  for (int i = 1, u, x; i <= m; i++) {
    u = read();
    x = read();
    b[col[u]].push_back((Data){u, i});
    b[col[u] = x].push_back((Data){u, i});
  }
  for (int i = 1; i <= n; i++) solve(b[i]);
  printf("%lld\n", buf - ans[0]);
  for (int i = 1; i <= m; i++) printf("%lld\n", buf - (ans[i] += ans[i - 1]));
  return 0;
}