Problem - D - Codeforces
Problem - D - Codeforces
|
QuanVanHoang | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN
what number will be in the cell at the x -th row and y-th column;
in which cell coordinates will the number d be located.
sets.
In the first line of each data set, there is an integer n, describing the size of the table
(1 ≤ n ≤ 30) .
In the second line of each data set, there is an integer q — the number of questions
(1 ≤ q ≤ 20 000).
In the following q lines of each data set, the questions are described in the following formats:
It is guaranteed that the sum of q over all test cases does not exceed 20 000.
Output
Output the answers to each question on a separate line.
Example
input Copy
2
2
5
-> 4 3
<- 15
<- 4
-> 3 1
-> 1 3
1
8
-> 1 1
-> 1 2
-> 2 1
-> 2 2
https://codeforces.com/contest/2093/problem/D 1/2
23:06 8/4/25 Problem - D - Codeforces
<- 1
<- 2
<- 3
<- 4
output Copy
7
2 3
1 2
9
13
1
4
3
2
1 1
2 2
2 1
1 2
Note
This is how the filled table from the first example looks:
Supported by
https://codeforces.com/contest/2093/problem/D 2/2