#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <fstream>
#include <iostream>
#include <cstdio>
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define down(i, l, r) for (int i = l; i >= r; i--)
#define MS 123456
#define MAX 1037471823
using namespace std;
struct edge { int y, n; } e[MS*2]; int ec, f[MS];
int tc, tl[MS*5], tr[MS*5], tn[MS*5], tlc[MS*5], trc[MS*5], tb[MS*5]; bool td[MS*5];
int n, m, s[MS], d[MS], h[MS], c[MS], x, y, z, lc, rc, ans;
int ln, lb[MS], lr[MS], ld[MS], ls[MS], lh[MS];
char q[10];
void Cal(int o) { tn[o] = tn[tl[o]] + tn[tr[o]]; if (trc[tl[o]] == tlc[tr[o]]) tn[o]--; tlc[o] = tlc[tl[o]], trc[o] = trc[tr[o]]; }
void Down(int o) { if (td[o]) td[o] = 0, tn[tl[o]] = tn[tr[o]] = td[tl[o]] = td[tr[o]] = 1, tlc[tl[o]] = tlc[tr[o]] = trc[tl[o]] = trc[tr[o]] = tlc[o]; }
void Search(int x, int n)
{
int o = f[x], m = 0, my = 0, y = e[o].y; s[x] = 1, d[x] = n;
while (y) { if (y != h[x]) { h[y] = x; Search(y, n+1); s[x] += s[y]; if (m < s[y]) m = s[y], my = y; } o = e[o].n, y = e[o].y; }
o = f[x], y = e[o].y;
while (y) { if (y != h[x] && y != my) { ld[lb[y]] = n+1, ls[lb[y]] = lr[y], lh[lb[y]] = x; } o = e[o].n, y = e[o].y; }
if (my) lb[x] = lb[my], lr[x] = lr[my]+1; else ln++, lb[x] = ln, lr[x] = 1;
}
void Build(int l, int r, int o) { if (l == r) return; int m = (l+r)/2; tl[o] = ++tc; Build(l, m, tc); tr[o] = ++tc; Build(m+1, r, tc); }
void Edit(int l, int r, int o)
{
if (x <= l && r <= y) { tn[o] = td[o] = 1, tlc[o] = trc[o] = z; return; }
int m = (l+r)/2; Down(o);
if (x <= m) Edit(l, m, tl[o]); if (m < y) Edit(m+1, r, tr[o]); Cal(o);
}
void QT(int l, int r, int o)
{
if (x <= l && r <= y) { ans += tn[o]; if (tlc[o] == lc) ans--; lc = trc[o]; return; }
int m = (l+r)/2; Down(o);
if (x <= m) QT(l, m, tl[o]); if (m < y) QT(m+1, r, tr[o]);
}
void QAQ(int a, int b)
{
int k; lc = rc = -1; while (lb[a] != lb[b])
{
if (ld[lb[a]] < ld[lb[b]]) k=a, a=b, b=k, k=lc, lc=rc, rc=k;
x = lr[a], y = ls[lb[a]]; QT(1, ls[lb[a]], tb[lb[a]]); a = lh[lb[a]];
}
if (d[a] < d[b]) k=a, a=b, b=k, k=lc, lc=rc, rc=k;
x = lr[a], y = lr[b]; QT(1, ls[lb[a]], tb[lb[a]]); if (lc == rc) ans--;
}
void EditQ(int a, int b)
{
int k; while (lb[a] != lb[b])
{
if (ld[lb[a]] < ld[lb[b]]) k=a, a=b, b=k;
x = lr[a], y = ls[lb[a]]; Edit(1, ls[lb[a]], tb[lb[a]]); a = lh[lb[a]];
}
if (d[a] < d[b]) k=a, a=b, b=k;
x = lr[a], y = lr[b]; Edit(1, ls[lb[a]], tb[lb[a]]);
}
int main()
{
scanf("%d%d", &n, &m);
rep(i, 1, n) scanf("%d", &c[i]);
rep(i, 1, n-1)
{
scanf("%d%d", &x, &y);
ec++, e[ec].y = y, e[ec].n = f[x], f[x] = ec;
ec++, e[ec].y = x, e[ec].n = f[y], f[y] = ec;
}
Search(1, 0); ld[lb[1]] = lh[lb[1]] = 0, ls[lb[1]] = lr[1];
rep(i, 1, ln) { tb[i] = ++tc; Build(1, ls[i], tc); }
rep(i, 1, n) { x = y = lr[i]; z = c[i]; Edit(1, ls[lb[i]], tb[lb[i]]); }
rep(i, 1, m)
{
scanf("%s%d%d", q, &x, &y);
if (q[0] == 'Q') { ans = 0; QAQ(x, y); printf("%d\n", ans); } else { scanf("%d", &z); EditQ(x, y); }
}
return 0;
}
I2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y3N0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