Hyunsoo City

Given a connected cactus graph with toggleable edges, answer connectivity queries under edge updates, where each edge lies on at most one cycle.

Hard8GraphDFSTreeUnion-findNo attempts yetTime limit1sMemory limit512 MB

Problem

Gyeonggi Science High School stands in Songjuk-dong, Jangan-gu, Suwon. The Songjuk-dong you know is not all of it. While you sleep, Songjuk-dong becomes part of a gloomy and dangerous city called Hyunsoo City.

Hyunsoo City is a frightening place sunk in darkness, but the mayor Hyunsoo is not a frightening man. He simply likes the dark, so he built Hyunsoo City. Because the city is dark, everyone stays away from it, and it turned into a hotbed of crime.

Hyunsoo City has NN intersections numbered 11 through NN, and MM roads join those intersections. You can travel between any two intersections along the roads. Kind Hyunsoo installed one street lamp on every road, and he laid out the city so that every road belongs to at most one cycle, so that people do not get lost.

Lately Hyunsoo has a new worry. The lamps on the roads keep breaking. He repairs them as they break, but he cannot keep up. Walking a road whose lamp is out is truly dangerous, so Hyunsoo wants citizens to use only roads whose lamps are on. He wants to build an app that reports in real time whether two intersections can be reached from each other using only roads whose lamps are on.

Hyunsoo is busy, so he handed the work of building the app to you. Help Hyunsoo out!

Input

The first line contains the number of intersections NN (1N2000001 \le N \le 200\,000) and the number of roads MM (N1M200000N-1 \le M \le 200\,000).

Each of the next MM lines contains the numbers uu and vv of the two intersections that one road joins. (1u,vN1 \le u, v \le N)

No two roads join the same pair of intersections, and no road returns to its own intersection. Every road is guaranteed to belong to at most one cycle.

The next line contains, in order and separated by spaces, whether the lamp on the ii-th road of the input is working. It is 11 if the lamp works and 00 if it is broken.

The next line contains the number of updates and queries QQ (1Q2000001 \le Q \le 200\,000) that reach the app.

Each of the next QQ lines contains one update or query, in order. Each line holds two or three numbers, with the following meaning.

11 ii : the lamp on the ii-th road of the input changes state. If it was broken it gets repaired, and if it was working it breaks. (1iM1 \le i \le M)

22 aa bb : asks whether, with the lamps in their current state, you can travel between intersection aa and intersection bb using only roads whose lamps are on. aa and bb may be the same intersection. (1a,bN1 \le a, b \le N)

Output

For each query, meaning each line that starts with 22, print one line. Print YES if the two intersections can be reached from each other using only roads whose lamps are on, and NO otherwise.