This page is still under construction.

Parts of this page are still being built. What you see may change.

Calculate! 2

Time limit1sMemory limit512 MB

Summary
On a rooted tree, handle subtree XOR queries and subtree XOR updates, printing the XOR of a vertex and its descendants.
Level

Medium7 of 10

Topics
Tree, Segment tree, DFS, Bit manipulation
Solved
No attempts yet

Problem

At Calculate! in the 3rd IUPC, Gyojeong answered every logic operation question that Ingyu asked. The 4th IUPC was held a year later, and this time Ingyu wanted to trip Gyojeong up, so he prepared a hard logic operation problem that Gyojeong cannot answer quickly.

The problem Ingyu prepared is the following.

  • A tree with NN vertices is given. The root is always vertex 1. A tree is a connected graph with NN vertices and N−1N-1 edges and no cycle.
  • Each vertex carries one weight DD.
  • MM queries are processed in the order they are given.
  • A query of the form 1 x prints the XOR of the weights of vertex xx and all descendants of xx.
  • A query of the form 2 x y XORs yy into the weight of vertex xx and into the weight of every descendant of xx.

Gyojeong's answers have to be checked. Write a program that prints the answer to every query of the form 1 x.

Input

The first line contains the number of vertices NN (3≤N≤100 0003 \le N \le 100\,000) and the number of queries MM (3≤M≤500 0003 \le M \le 500\,000).

Each of the next N−1N-1 lines contains two integers AA and BB, which means that vertex AA and vertex BB are joined by an edge.

The next line contains NN numbers separated by spaces. The ii-th number is the weight DiD_i (0≤Di≤10 0000 \le D_i \le 10\,000) of vertex ii.

Each of the next MM lines contains one query, either 1 x or 2 x y, with 1≤x≤N1 \le x \le N and 0≤y≤10 0000 \le y \le 10\,000.

Output

For every query of the form 1 x, print the answer on its own line, in the order the queries are given.

Examples2

  1. Example 1

    Input
    5 4
    1 2
    2 3
    2 4
    3 5
    1 2 3 4 5
    1 1
    2 3 100
    2 1 94
    1 4
    
    Expected output
    1
    90
    
  2. Example 2

    Input
    7 10
    1 2
    1 3
    1 4
    4 5
    4 6
    6 7
    49 38 29 40 3 59 0
    2 7 45
    2 3 30
    1 7
    1 5
    1 1
    2 1 2
    1 4
    2 6 15
    1 1
    1 2
    
    Expected output
    45
    3
    41
    61
    43
    36