Old Orhei
시간 제한3초메모리 제한2048 MB
정점 수가 50 이하인 그래프에서 함수들의 수열을 구간마다 시작 정점에 적용한 결과를 구하고, 수열의 원소를 갱신하는 문제.
문제
Old Orhei (Orheiul Vechi) is a natural and historical complex located on a narrow bend of the Răut River. It consists of archaeological vestiges and one-way roads between some pairs of vestiges. Every road has a unique index between and , defined by the input order in which it is given. Please refer to the Examples section for visualizing such a configuration.
Recently an array left by the Cucuteni–Trypillia civilization was discovered by the local scientists. The array consists of integers with values between and . In order to figure out the mystical meaning of this array, the new intern will be instructed to follow this procedure:
At the beginning, the intern starts at some initial archaeological vestige. The other scientists start broadcasting to him a contiguous sub-array of the main array (first broadcasting the first element of the subarray, then the second one, and so on). The intern then changes his location depending on the following rules:
- If the intern can use the road indexed with the current broadcast number (in other words, the intern's current location is equal to the starting point of the corresponding road), the intern traverses it (goes to the end-point of the corresponding road).
- Otherwise the intern does nothing, and remains in his current location.
With the occasion of the -th European Junior Olympiad in Informatics, the local scientists have asked you to help them perform the following queries:
- - the scientists want to know what will be the final location of the intern if initially he is located in the -th vestige, and only the contiguous sub-array of the initial array which starts at index and ends at index is broadcasted.
- - the scientists override the -th element of the array with the value . The change is permanent. (In other words, the array changes so that after performing the query).
Your task is to answer correctly to all the queries of type .
입력
The first line contains two space-separated integers and , the number of archaeological vestiges and one-way roads.
The next lines contain the description of the roads. In particular, line i will contain two space-separated numbers indicating that the -th road starts in and ends in . There can exist roads for which as well as pairs of roads for which , but .
The next line contains an integer , the length of the found array.
The next line contains space-separated integers , representing the array elements.
The next line contains an integer , the number of queries.
The next lines contain the query description:
- for a query of type .
- for a query of type .
출력
For each query of type output the answer on a separate line.