#include <bits/stdc++.h>
using namespace std;
inline int gi() {
  int data = 0, fu = 1;
  char ch = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') fu = -1, ch = getchar();
  while ('0' <= ch && ch <= '9')
    data = (data << 1) + (data << 3) + (ch ^ 48), ch = getchar();
  return data * fu;
}
int ch[2][400005], fa[400005], Fa[400005], sz[400005], xz[400005], col[400005],
    n, m;
vector<int> edge[400005];
bool Del[400005];
long long sum[400005], ans[400005], Ans;
bool cht;
vector<pair<int, int> > Act[400005];
inline void DeBug() {
  for (int i = 1; i <= n; ++i)
    printf("Node%d: fa=%d, lson=%d, rson=%d, sz=%d, xz=%d, sum=%lld\n", i,
           fa[i], ch[0][i], ch[1][i], sz[i], xz[i], sum[i]);
  return cout << "================================================"
              << " ; ans[0]=" << ans[0] << endl,
         void();
}
inline long long Sqr(int x) { return 1ll * x * x; }
inline bool Son(int x) { return ch[1][fa[x]] == x; }
inline bool Isroot(int x) { return ch[0][fa[x]] != x && ch[1][fa[x]] != x; }
inline void PushUp(int x) { sz[x] = sz[ch[1][x]] + sz[ch[0][x]] + xz[x] + 1; }
inline void Rot(int x) {
  int y = fa[x], z = fa[y], c = Son(x);
  if (!Isroot(y)) ch[Son(y)][z] = x;
  fa[x] = z;
  fa[ch[c][y] = ch[!c][x]] = y;
  fa[ch[!c][x] = y] = x;
  PushUp(y);
}
inline void Splay(int x) {
  for (int y = fa[x]; !Isroot(x); Rot(x), y = fa[x])
    if (!Isroot(y)) Son(x) ^ Son(y) ? Rot(x) : Rot(y);
  PushUp(x);
}
inline void Access(int x) {
  for (int y = 0, z; x; y = x, x = fa[x]) {
    Splay(x);
    z = ch[1][x];
    if (y) sum[x] -= 1ll * sz[y] * sz[y], xz[x] -= sz[y];
    if (z) sum[x] += 1ll * sz[z] * sz[z], xz[x] += sz[z];
    ch[1][x] = y;
    PushUp(x);
  }
  return;
}
inline int Size(int x) {
  Access(x);
  if (cht) DeBug();
  Splay(x);
  while (ch[0][x]) x = ch[0][x];
  Splay(x);
  return sz[ch[1][x]];
}
inline long long Link(int x, int f) {
  Del[x] = false;
  long long ret = 0;
  if (!Del[f]) ret -= Sqr(Size(f));
  Splay(x);
  ret -= sum[x] + Sqr(sz[ch[1][x]]);
  Splay(f);
  fa[x] = f;
  xz[f] += sz[x];
  sum[f] += 1ll * sz[x] * sz[x];
  PushUp(f);
  ret += Sqr(Size(x));
  return ret;
}
inline long long Cut(int x, int f) {
  Del[x] = true;
  long long ret = 0;
  ret = -Sqr(Size(x));
  Splay(x);
  Splay(f);
  ch[1][f] = fa[x] = 0;
  PushUp(f);
  if (!Del[f]) ret += Sqr(Size(f));
  ret += sum[x];
  return ret;
}
void dfs(int u, int From) {
  sz[u] = 1;
  Fa[u] = From;
  for (auto v : edge[u])
    if (v != From) dfs(v, u);
  if (From) Link(u, From);
  return;
}
int main() {
  n = gi();
  m = gi();
  for (int i = 1, c; i <= n; ++i)
    c = gi(), Act[c].push_back(make_pair(0, -i)), col[i] = c;
  for (int i = 1, u, v; i < n; ++i)
    u = gi(), v = gi(), edge[u].push_back(v), edge[v].push_back(u);
  edge[++n].push_back(1);
  dfs(n, 0);
  for (int i = 1, u, x; i <= m; ++i) {
    u = gi(), x = gi();
    Act[col[u]].push_back(make_pair(i, u));
    col[u] = x;
    Act[col[u]].push_back(make_pair(i, -u));
  }
  int u;
  for (int c = 1; c < n; ++c) {
    ans[0] += 1ll * (n - 1) * (n - 1);
    for (auto upd : Act[c]) {
      u = upd.second;
      if (u < 0)
        u = -u, ans[upd.first] += Cut(u, Fa[u]);
      else
        ans[upd.first] += Link(u, Fa[u]);
      u = abs(u);
    }
    cht = false;
    for (auto upd : Act[c]) {
      u = abs(upd.second);
      if (Del[u]) Link(u, Fa[u]);
    }
  }
  Ans = 0;
  --n;
  for (int t = 0; t <= m; ++t)
    Ans += ans[t], printf("%lld\n", 1ll * n * n * n - Ans);
  return 0;
}
