시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
5 초 | 512 MB | 1 | 1 | 1 | 100.000% |
Just going into the second grade, little Q has purchased a popular educational game — the magic chessboard! This game takes place on an N row by M column grid, where each grid cell contains a single positive integer. The chessboard guardian is located at row X, column Y(rows and columns are numbered starting from 1) and will never move. The chessboard guardian will perform two types of operations:
The game's instruction manual contains an message reading "My smart young friends, when you have continuously answered 19930324 correct queries, there will be a surprise!" Little Q is incredibly eager to discover the surprise, so he plays this game every day. However due to his carelessness, mistakes are very often made. So, he has come to you for help, hoping that you can write a program to help him correctly answer the chessboard guardian's queries 100% of the time.
To make this problem simpler, your program will only need to complete T operations of the chessboard guardian. It is guaranteed that all numbers on the chessboard will be positive integers not exceeding 262 − 1.
The first line of input contains two positive integers N and M, representing the dimensions of the chessboard.
The second line contains two positive integers X and Y, representing the chessboard guardian's position.
The third line contains a positive integer T, representing the number of operations carried out by the chessboard guardian.
For the following N lines, each line contains M integers, describing the numbers in all of the grid cells.
For the following T lines, each line will describe a single operation. Each line will start with either the number 0 or 1:
For each query, output a single number on a separate line representing the greatest common divisor of the queried region.
2 2 1 1 4 6 12 18 24 0 0 0 1 0 1 1 1 1 2 6 1 2 1 2 2 6 0 0 0 1 1
6 6