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;
class node {
 public:
  node* l;
  node* r;
  node* p;
  long long square_light;
  int light;
  int size;
  int id;
  node(int id) : id(id) {
    l = r = p = NULL;
    square_light = 0;
    light = size = 1;
  }
  void pull() {
    size = light;
    if (l != NULL) {
      l->p = this;
      size += l->size;
    }
    if (r != NULL) {
      r->p = this;
      size += r->size;
    }
  }
};
bool is_bst_root(node* v) {
  if (v == NULL) {
    return false;
  }
  return (v->p == NULL || (v->p->l != v && v->p->r != v));
}
void rotate(node* v) {
  node* u = v->p;
  assert(u != NULL);
  v->p = u->p;
  if (v->p != NULL) {
    if (v->p->l == u) {
      v->p->l = v;
    }
    if (v->p->r == u) {
      v->p->r = v;
    }
  }
  if (v == u->l) {
    u->l = v->r;
    v->r = u;
  } else {
    u->r = v->l;
    v->l = u;
  }
  u->pull();
  v->pull();
}
void splay(node* v) {
  if (v == NULL) {
    return;
  }
  while (!is_bst_root(v)) {
    node* u = v->p;
    if (!is_bst_root(u)) {
      if ((u->l == v) ^ (u->p->l == u)) {
        rotate(v);
      } else {
        rotate(u);
      }
    }
    rotate(v);
  }
}
void access(node* v) {
  node* u = NULL;
  while (v != NULL) {
    splay(v);
    if (v->r != NULL) {
      v->square_light += (long long)v->r->size * v->r->size;
      v->light += v->r->size;
    }
    v->r = u;
    if (v->r != NULL) {
      v->square_light -= (long long)v->r->size * v->r->size;
      v->light -= v->r->size;
    }
    u = v;
    v = v->p;
  }
}
node* find_root(node* v) {
  access(v);
  splay(v);
  while (v->l != NULL) {
    v = v->l;
  }
  splay(v);
  return v;
}
long long link(node* v, node* u) {
  long long ans = 0;
  access(v);
  splay(v);
  ans -= v->square_light;
  node* w = find_root(u);
  access(w);
  ans -= w->square_light;
  access(u);
  splay(u);
  v->p = u;
  u->square_light += (long long)v->size * v->size;
  u->light += v->size;
  u->pull();
  access(w);
  splay(w);
  ans += w->square_light;
  return ans;
}
long long cut(node* v, node* u) {
  long long ans = 0;
  node* w = find_root(v);
  access(w);
  ans -= w->square_light;
  access(u);
  splay(u);
  v->p = NULL;
  u->square_light -= (long long)v->size * v->size;
  u->light -= v->size;
  u->pull();
  access(w);
  splay(w);
  ans += w->square_light;
  access(v);
  splay(v);
  ans += v->square_light;
  return ans;
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> c(n);
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    --c[i];
  }
  vector<vector<int>> adj(n);
  for (int i = 0; i < n - 1; ++i) {
    int from, to;
    cin >> from >> to;
    --from;
    --to;
    adj[from].push_back(to);
    adj[to].push_back(from);
  }
  vector<vector<pair<int, int>>> events(n);
  for (int i = 0; i < n; ++i) {
    events[c[i]].emplace_back(i, 0);
  }
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    events[c[x]].emplace_back(x, i);
    c[x] = y;
    events[c[x]].emplace_back(x, i);
  }
  vector<int> parent(n + 1);
  function<void(int)> dfs = [&](int x) {
    for (auto y : adj[x]) {
      if (y != parent[x]) {
        parent[y] = x;
        dfs(y);
      }
    }
  };
  parent[0] = n;
  dfs(0);
  vector<node*> tree(n + 1);
  for (int i = 0; i <= n; ++i) {
    tree[i] = new node(i);
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += link(tree[i], tree[parent[i]]);
  }
  vector<bool> black(n, true);
  vector<long long> add(m + 1);
  for (int i = 0; i < n; ++i) {
    long long last = ans;
    add[0] += last;
    for (auto p : events[i]) {
      if (black[p.first]) {
        ans += cut(tree[p.first], tree[parent[p.first]]);
      } else {
        ans += link(tree[p.first], tree[parent[p.first]]);
      }
      black[p.first] = !black[p.first];
      add[p.second] += ans - last;
      last = ans;
    }
    for (auto p : events[i]) {
      if (!black[p.first]) {
        ans += link(tree[p.first], tree[parent[p.first]]);
        black[p.first] = true;
      }
    }
  }
  long long cur = (long long)n * n * n;
  for (int i = 0; i <= m; ++i) {
    cur -= add[i];
    cout << cur << "\n";
  }
  return 0;
}