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;
using pii = pair<int, int>;
using INT = long long;
static char fjf[20202];
char gc() {
  static char *L = fjf, *R = L;
  if (L == R) {
    int n = fread(fjf, 1, 20202, stdin);
    if (!n) return -1;
    L = fjf, R = L + n;
  }
  return *L++;
}
void gn(int &first) {
  char c;
  while (c = gc(), (c < '0' || '9' < c) && ~c)
    ;
  if (!~c) return;
  for (first = c - 48; c = gc(), '0' <= c && c <= '9';
       first = 10 * first + c - 48)
    ;
}
bool rev[404040], flag[404040];
int pa[404040], son[404040][2];
INT num[404040], s2[404040], ans;
int sz[404040], vir[404040];
void push_up(int u) {
  int ls = son[u][0], rs = son[u][1];
  sz[u] = sz[ls] + sz[rs] + vir[u] + 1;
}
bool is_root(int u) { return son[pa[u]][0] != u && son[pa[u]][1] != u; }
void down(int u) {
  if (!is_root(u)) down(pa[u]);
  if (rev[u]) {
    swap(son[u][0], son[u][1]);
    rev[son[u][0]] ^= 1;
    rev[son[u][1]] ^= 1;
    rev[u] = false;
  }
}
void rot(int first, bool d) {
  int second = pa[first], z = pa[second];
  son[second][!d] = son[first][d];
  pa[son[first][d]] = second, pa[first] = pa[second];
  if (son[z][0] == second)
    son[z][0] = first;
  else if (son[z][1] == second)
    son[z][1] = first;
  pa[second] = first, son[first][d] = second;
  push_up(second);
}
void splay(int first) {
  down(first);
  int second, z;
  bool d;
  while (!is_root(first)) {
    if (is_root(pa[first]))
      rot(first, son[pa[first]][0] == first);
    else {
      second = pa[first], z = pa[second], d = son[z][0] == second;
      son[second][d] == first ? rot(first, !d) : rot(second, d);
      rot(first, d);
    }
  }
  push_up(first);
}
INT c2(int u) { return (INT)sz[u] * sz[u]; }
void access(int first) {
  for (int second = 0; first; first = pa[first]) {
    splay(first);
    vir[first] += sz[son[first][1]], s2[first] += c2(son[first][1]);
    son[first][1] = second, vir[first] -= sz[second], s2[first] -= c2(second);
    push_up(second = first);
  }
}
int get_root(int u) {
  access(u), splay(u);
  while (son[u][0]) u = son[u][0];
  return u;
}
void link(int u, int f) {
  splay(u), ans -= c2(son[u][1]) + s2[u];
  int first = get_root(f);
  splay(first);
  int up = sz[son[first][1]];
  ans += ((INT)(up + sz[u]) * (up + sz[u])) - ((INT)(up) * (up));
  pa[u] = f, s2[f] += ((INT)(sz[u]) * (sz[u]));
  vir[f] += sz[u], access(u);
}
void cut(int u, int f) {
  int first = get_root(f);
  access(u), splay(first), ans -= c2(son[first][1]);
  splay(u), pa[son[u][0]] = 0;
  son[u][0] = 0;
  splay(first), ans += c2(son[first][1]) + s2[u];
}
int c[404040], fa[404040];
vector<int> adj[404040];
vector<pii> col[404040];
void dfs(int u) {
  link(u, fa[u]);
  for (int v : adj[u])
    if (v != fa[u]) {
      fa[v] = u, dfs(v);
    }
}
int main() {
  int n, m;
  gn(n), gn(m);
  for (int i = 1; i <= n; i++) {
    gn(c[i]), col[c[i]].push_back({i, 0});
  }
  for (int i = 1, u, v; i < n; i++) {
    gn(u), gn(v);
    adj[u].push_back(v), adj[v].push_back(u);
  }
  for (int i = 1, u; i <= m; i++) {
    gn(u), col[c[u]].push_back({u, i});
    gn(c[u]), col[c[u]].push_back({u, i});
  }
  fa[1] = n + 1, dfs(1);
  for (int c = 1; c <= n; c++) {
    if (col[c].empty()) {
      num[0] += ((INT)(n) * (n));
      continue;
    }
    INT pre = 0;
    if (col[c][0].second) {
      pre = ((INT)(n) * (n)), num[0] += pre;
    }
    for (int i = 0, j = 0; i < col[c].size(); i = j) {
      for (; j < col[c].size() && col[c][i].second == col[c][j].second; j++) {
        int u = col[c][j].first;
        if (flag[u] ^= 1)
          cut(u, fa[u]);
        else
          link(u, fa[u]);
      }
      num[col[c][i].second] += ans - pre, pre = ans;
    }
    for (int i = col[c].size(); i--;) {
      int u = col[c][i].first;
      if (flag[u] ^= 1)
        cut(u, fa[u]);
      else
        link(u, fa[u]);
    }
  }
  ans = ((INT)(n) * (n)) * n;
  for (int i = 0; i <= m; i++) {
    printf("%I64d\n", ans -= num[i]);
  }
}