This page is still under construction.

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

Cow Land

Time limit2sMemory limit512 MB

Summary
On a weighted tree, support point value updates and path XOR queries between any two nodes, returning the XOR of enjoyment values along the unique route.
Level

Hard8 of 10

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

Problem

Cow Land is a special amusement park for cows. They roam around, eat delicious grass, and visit the various cow attractions (the roller cowster is especially popular).

There are NN attractions in total (2≤N≤1052 \leq N \leq 10^5). Some pairs of attractions are connected by pathways, N−1N-1 in total, so that a unique route made up of pathways exists between any two attractions. Attraction ii has an integer enjoyment value eie_i. This value can change over the course of a day, since some attractions are more appealing in the morning and others later in the afternoon.

A cow that travels from attraction ii to attraction jj experiences every attraction on the route from ii to jj. Curiously, the enjoyment of this entire route is the bitwise XOR of all the enjoyment values along the route, including those of attractions ii and jj.

Help the cows determine the enjoyment values of the routes they plan to use on their next trip to Cow Land.

Input

The first line contains NN and the number of queries QQ (1≤Q≤1051 \leq Q \leq 10^5). The next line contains e1…eNe_1 \ldots e_N (0≤ei≤1090 \leq e_i \leq 10^9). The next N−1N-1 lines each describe a pathway with two integer attraction IDs aa and bb (both in the range 1…N1 \ldots N). The last QQ lines each describe either an update to one of the eie_i values or a query for the enjoyment of a route. A line of the form "1 ii vv" means eie_i should be updated to value vv, and a line of the form "2 ii jj" is a query for the enjoyment of the route connecting attractions ii and jj.

In test data worth at most 50% of the points, the attraction values never change.

Output

For each query of the form "2 ii jj", print the enjoyment of the route from ii to jj on a single line.

Examples1

  1. Example 1

    Input
    5 5
    1 2 4 8 16
    1 2
    1 3
    3 4
    3 5
    2 1 5
    1 1 16
    2 3 5
    2 1 5
    2 1 3
    
    Expected output
    21
    20
    4
    20