Tokitsukaze has a rooted tree with $n$ nodes, whose nodes are labeled from $1$ to $n$ and whose root is node $1$. Furthermore, each node $i$ has its own color $col_i$ and its own weight $val_i$, where the color is labeled as a number between $1$ and $n$, representing one of $n$ given colors.
Here are two types of operation:
● $1$ $x$ $v$ -- set $val_x$ as $v$.
● $2$ $x$ $c$ -- set $col_x$ as $c$.
Tokitsukaze wants to execute $q$ opeations and for $i = 1, 2, \ldots, q + 1$, after finishing the first $(i - 1)$ operations, she wants to know the value of $$\sum_{\substack{1 \leq u < v \leq n \\ col_u = col_v \\ \text{node }u\text{ is not an ancestor of node }v \\ \text{node }v\text{ is not an ancestor of node }u}}{(val_u \oplus val_v)}$$ where $\oplus$ is the bitwise exclusive OR operation.
If you are not familiar with the bitwise exclusive OR, you may refer to
http://en.wikipedia.org/wiki/Bitwise_operation#XOR and
http://baike.baidu.com/item/xor/64178.