If faith has a color, it must be miserable red.
A tree is an undirected connected graph without cycles.
You are given a tree of $n$ nodes numbered from $1$ to $n$ The root of the tree is a node number $1$.
The color of $i$-th node is $i$.
For each node $u$ and node $v$ which are connected by an edge, the weight of edge is $1$ if the color of node $u$ is different from the color of node $v$ otherwise the weight of edge is $0$.
Let's denote path between node $u$ and node $v$ as $(u,v)$.
Let's denote the number of edges in $(u,v)$ as $d(u,v)$.
Let's denote the sum of weighted edges in $(u,v)$ as $dist(u,v)$.
if $u$ is an ancestor of $v$ and $v$ is an ancestor of $w$ then $u$ is an ancestor of $w$.
$v\in subtree(u)$ if $u$ is an ancestor of $v$.
Let's denote $max_{i=1}^n d(i,u)$ as $FakeDeep_u$, while $dist(i,u)=0$ and $i$ is an ancestor of $u$.
There are $m$ queries. Each query has one of four types:
$1$ $u$ $c$: change the color of nodes in $(u,1)$ to $c$, $c$ is different from any other color in the tree.
$2$ $u$ $v$: print $dist(u,v)$.
$3$ $u$: print $\sum_{i=1}^n dist(i,u),i\in subtree(u)$.
$4$ : print $\sum_{i=1}^n FakeDeep_i$.