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;
long long sq(int x) { return (long long)x * x; }
struct ND {
  ND *p, *l, *r, *fa;
  int sz, z;
  long long sz2, z2;
  ND() : p(0), l(0), r(0), fa(0), sz(0), z(0), sz2(0), z2(0) {}
  void up();
  void stR(ND *);
};
ND *L(ND *v) {
  while (v->l) v = v->l;
  return v;
}
int gsz(ND *v) { return v ? v->sz : 0; }
void ND::up() {
  sz = 1 + gsz(l) + gsz(r) + z;
  sz2 = sq(gsz(r)) + z2;
}
void RR(ND *v) {
  ND *p = v->p;
  p->l = v->r;
  if (v->r) v->r->p = p;
  v->r = p;
}
void RL(ND *v) {
  ND *p = v->p;
  p->r = v->l;
  if (v->l) v->l->p = p;
  v->l = p;
}
void R(ND *v) {
  ND *p = v->p;
  if (p->l == v)
    RR(v);
  else
    RL(v);
  v->p = p->p;
  if (p->p) (p->p->l == p ? p->p->l : p->p->r) = v;
  p->p = v;
  p->up();
  v->up();
}
void SP(ND *v) {
  while (v->p) {
    if (!v->p->p)
      R(v);
    else if (v->p->l == v ^ v->p->p->l == v->p)
      R(v), R(v);
    else
      R(v->p), R(v);
  }
}
void ND::stR(ND *v) {
  if (r) {
    z += r->sz;
    z2 += sq(r->sz);
    r->p = 0;
    ND *l = L(r);
    l->fa = this;
    SP(l);
  }
  if (v) {
    z -= v->sz;
    z2 -= sq(v->sz);
    v->p = this;
  }
  r = v;
  up();
}
void AC(ND *v) {
  SP(v);
  v->stR(0);
  while (true) {
    ND *l = L(v);
    if (!l->fa) return;
    SP(l->fa);
    l->fa->stR(v);
    l->fa = 0;
    SP(l);
    SP(v);
  }
}
void LN(ND *p, ND *v) {
  AC(p);
  AC(v);
  p->r = v;
  v->p = p;
  p->up();
}
void CT(ND *v) {
  AC(v);
  v->l->p = 0;
  v->l = 0;
}
int const N = 400000;
vector<int> tr[N + 1];
int n, m, pa[N + 1], cc[N + 1];
long long an[N + 1];
set<int> fl;
vector<pair<int, int> > cl[N + 1];
ND *x[N + 1];
void pl(int v = 1, int p = 0) {
  pa[v] = p;
  for (int u : tr[v])
    if (u != p) pl(u, v);
}
long long flp(int v) {
  AC(x[pa[v]]);
  long long an;
  ND *l = L(x[pa[v]]);
  auto it = fl.find(v);
  if (it == fl.end()) {
    fl.insert(v);
    AC(l);
    an = -l->sz2;
    CT(x[v]);
    AC(l);
    AC(x[v]);
    an += x[v]->sz2 + l->sz2;
  } else {
    fl.erase(it);
    AC(l);
    AC(x[v]);
    an = -(l->sz2 + x[v]->sz2);
    LN(x[pa[v]], x[v]);
    AC(l);
    an += l->sz2;
  }
  return an;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < (int)(n + 1); ++i) {
    int t;
    scanf("%d", &t);
    cl[t].emplace_back(0, i);
    cc[i] = t;
  }
  for (int i = 1; i < (int)(n); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    tr[a].push_back(b);
    tr[b].push_back(a);
  }
  pl();
  for (int i = 0; i < (int)(n + 1); ++i) x[i] = new ND();
  for (int i = 1; i < (int)(m + 1); ++i) {
    int v, c;
    scanf("%d%d", &v, &c);
    cl[cc[v]].emplace_back(i, v);
    cl[c].emplace_back(i, v);
    cc[v] = c;
  }
  an[0] = sq(n) * n;
  for (int i = 1; i < (int)(n + 1); ++i) fl.insert(i);
  for (int i = n; i > 0; --i) flp(i);
  AC(x[0]);
  for (int i = 1; i < (int)(n + 1); ++i) {
    for (int j = 0; j < (int)(cl[i].size()); ++j)
      an[cl[i][j].first] += flp(cl[i][j].second);
    while (!fl.empty()) flp(*fl.begin());
  }
  for (int i = 1; i < (int)(m + 1); ++i) an[i] += an[i - 1];
  for (int i = 0; i < (int)(m + 1); ++i) an[i] = sq(n) * n - an[i];
  for (int i = 0; i < (int)(m + 1); ++i) printf("%lld\n", an[i]);
  for (int i = 0; i < (int)(n + 1); ++i) delete x[i];
}