//Let's join Kaede Takagaki Fan Club !! #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include #include #include using namespace std; typedef long long ll; typedef pair P; typedef pair P1; typedef pair P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define fi first #define sc second #define rep(i,x) for(int i=0;i void dmp(T a){ rep(i,a.size()) cout << a[i] << " "; cout << endl; } template bool chmax(T&a, T b){ if(a < b){ a = b; return 1; } return 0; } template bool chmin(T&a, T b){ if(a > b){ a = b; return 1; } return 0; } template void g(T &a){ cin >> a; } template void o(const T &a,bool space=false){ cout << a << (space?' ':'\n'); } //ios::sync_with_stdio(false); const ll mod = 998244353; template void add(T&a,T b){ a+=b; if(a >= mod) a-=mod; } #define SZ 100005 vectoredge[SZ]; P ar[SZ*2]={}; int pos[SZ]={},id=0,up[SZ],dep[SZ]; P mn[2][20][SZ*2]={}; int sz[SZ*2]={},in[SZ],out[SZ],rev[SZ*2]; struct adj_finder{ //SZは元の木の頂点数より大 //外部でedge[]に隣接状況を持って置く必要あり void dfs(int v,int u,int d){ pos[v] = in[v] = id; up[v] = u; dep[v] = d; rev[id] = v; ar[id++] = mp(d,id); for(int i=0;i= id) rep(x,2) mn[x][j+1][i] = mn[x][j][i]; else{ mn[0][j+1][i] = min(mn[0][j][i], mn[0][j][i+(1<Q; ll sum[100005]; int sub[100005]; int upp[100005], arr[100005], idd, D[100005]; void make(int v, int u){ arr[idd++] = v; upp[v] = u; if(u == -1) D[v] = 0; else D[v] = D[u]+1; rep(i, edge[v].size()){ if(edge[v][i] == u) continue; make(edge[v][i], v); } } /*void dfs(int v, int u, int d){ sum[1] += 1LL * d * cnt[v]; rep(i, edge[v].size()){ if(edge[v][i] == u) continue; dfs(edge[v][i], v, d+1); sub[v] += sub[edge[v][i]]; } sub[v] += cnt[v]; } void dfs2(int v, int u){ rep(i, edge[v].size()){ if(edge[v][i] == u) continue; sum[edge[v][i]] = sum[v] + k - 2*sub[edge[v][i]]; dfs2(edge[v][i], v); } }*/ void maketree(){ rep(i, n){ int v = arr[i]; sum[1] += 1LL*D[v]*cnt[v]; sub[v] += cnt[v]; if(v != 1) sub[upp[v]] += sub[v]; } for(int i=n-1;i>=0;i--){ int v = arr[i]; if(v != 1){ sum[v] = sum[upp[v]] + k - 2 * sub[v]; } } } int main(){ scanf("%d%d%d", &n, &k, &q); repn(i, k){ scanf("%d", &c[i]); } rep(i, n-1){ int a, b; scanf("%d%d", &a, &b); edge[a].pb(b); edge[b].pb(a); } kaede.prepare(); make(1, -1); reverse(arr, arr+n); rep(i, q){ int ty; scanf("%d", &ty); int a, b = -1; if(ty == 1) scanf("%d%d", &a, &b); else scanf("%d", &a); Q.pb(mp(ty, mp(a, b))); } for(int i=0;ivec; for(int j=i;jgen; rep(i, vec.size()) gen.pb(c[vec[i]]); for(int j=i;j