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 = 400005;
using ll = long long;
struct TNode {
  int ch[2], f;
  ll v;
};
TNode t[N];
ll val[N], val2[N];
inline bool isroot(int pos) {
  return t[t[pos].f].ch[0] != pos && t[t[pos].f].ch[1] != pos;
}
inline void pushup(int pos) {
  t[pos].v = t[t[pos].ch[0]].v + val[pos] + t[t[pos].ch[1]].v + 1;
}
void rotate(int pos) {
  int y = t[pos].f, z = t[y].f, k = t[y].ch[1] == pos, w = t[pos].ch[k ^ 1];
  if (!isroot(y)) t[z].ch[t[z].ch[1] == y] = pos;
  t[pos].f = z;
  t[pos].ch[!k] = y;
  t[y].ch[k] = w;
  t[w].f = y;
  t[y].f = pos;
  pushup(y);
  pushup(pos);
}
void splay(int pos) {
  while (!isroot(pos)) {
    int y = t[pos].f, z = t[y].f;
    if (!isroot(y)) rotate((t[y].ch[0] == pos) ^ (t[z].ch[0] == y) ? pos : y);
    rotate(pos);
  }
}
void access(int pos) {
  for (int last = 0; pos; pos = t[last = pos].f) {
    splay(pos);
    val[pos] += t[t[pos].ch[1]].v;
    val2[pos] += t[t[pos].ch[1]].v * t[t[pos].ch[1]].v;
    t[pos].ch[1] = last;
    val[pos] -= t[t[pos].ch[1]].v;
    val2[pos] -= t[t[pos].ch[1]].v * t[t[pos].ch[1]].v;
    pushup(pos);
  }
}
inline void makeroot(int pos) {
  access(pos);
  splay(pos);
}
int findroot(int pos) {
  access(pos);
  splay(pos);
  while (t[pos].ch[0]) pos = t[pos].ch[0];
  splay(pos);
  return pos;
}
ll ans;
inline void add(int x, int v) {
  int rt;
  makeroot(rt = findroot(x));
  ans += v * val2[rt];
}
inline void link(int x, int y) {
  add(x, -1);
  add(y, -1);
  makeroot(x);
  makeroot(y);
  t[x].f = y;
  val[y] += t[x].v;
  val2[y] += t[x].v * t[x].v;
  add(y, 1);
}
inline void cut(int x, int y) {
  add(x, -1);
  makeroot(x);
  t[t[x].ch[0]].f = 0;
  t[x].ch[0] = 0;
  pushup(x);
  add(x, 1);
  add(y, 1);
}
int fa[N], n, m, a[N];
bool vis[N];
vector<int> v[N];
vector<pair<int, int>> vv[N];
void dfs(int pos) {
  for (auto &i : v[pos])
    if (i != fa[pos]) fa[i] = pos, dfs(i);
}
ll final_ans[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i], vv[a[i]].push_back({i, 0});
  int t1, t2;
  for (int i = 1; i < n; i++)
    cin >> t1 >> t2, v[t1].push_back(t2), v[t2].push_back(t1);
  dfs(1);
  fa[1] = n + 1;
  for (int i = 1; i <= m; i++)
    cin >> t1 >> t2, vv[a[t1]].push_back({t1, i}),
        vv[a[t1] = t2].push_back({t1, i});
  for (int i = 1; i <= n + 1; i++) t[i].v = 1;
  for (int i = 1; i <= n; i++) link(i, fa[i]);
  for (int i = 1; i <= n; i++) {
    ll lst = 0;
    for (auto &j : vv[i]) {
      int x = j.first;
      if (vis[x])
        link(x, fa[x]);
      else
        cut(x, fa[x]);
      vis[x] ^= 1;
      final_ans[j.second] += 1ll * n * n - ans - lst;
      lst = 1ll * n * n - ans;
    }
    for (auto &j : vv[i])
      if (vis[j.first]) vis[j.first] = 0, link(j.first, fa[j.first]);
  }
  for (int i = 1; i <= m; i++) final_ans[i] += final_ans[i - 1];
  for (int i = 0; i <= m; i++) cout << final_ans[i] << endl;
  return 0;
}