In the Country of Unlearned Lessons
Victor found himself in a land of unlearned lessons. To return home, he must complete various tasks. One such task involves defeating a guard in a GCD game. The rules are straightforward: given an array of positive integers, the players select two numbers and , and find the greatest common divisor (GCD) of all the elements in the array from index to inclusive. The player who finds the GCD the fastest wins. To prevent unfair play, some numbers in the array may be replaced occasionally.
Victor is eager to return home. Help him by writing a program that can quickly calculate the GCD over a specified interval.
Input
The first line contains the number of elements in array. The second line contains integers — the elements of array. The third line gives the number of queries . Each of the next lines contains three integers .
If , find the GCD of elements on an interval ;
If , change the element at position to number .
Output
For each query with number print the answer on a separate line.