题干:

You are given a chessboard of size n×nn×n. It is filled with numbers from 11 to n2n2 in the following way: the first ⌈n22⌉⌈n22⌉ numbers from 11 to ⌈n22⌉⌈n22⌉ are written in the cells with even sum of coordinates from left to right from top to bottom. The rest n2−⌈n22⌉n2−⌈n22⌉ numbers from ⌈n22⌉+1⌈n22⌉+1 to n2n2 are written in the cells with odd sum of coordinates from left to right from top to bottom. The operation ⌈xy⌉⌈xy⌉ means division xx by yy rounded up.

For example, the left board on the following picture is the chessboard which is given for n=4n=4 and the right board is the chessboard which is given for n=5n=5.

You are given qq queries. The ii-th query is described as a pair xi,yixi,yi. The answer to the ii-th query is the number written in the cell xi,yixi,yi (xixi is the row, yiyi is the column). Rows and columns are numbered from 11 to nn.

Input

The first line contains two integers nn and qq (1≤n≤1091≤n≤109, 1≤q≤1051≤q≤105) — the size of the board and the number of queries.

The next qq lines contain two integers each. The ii-th line contains two integers xi,yixi,yi(1≤xi,yi≤n1≤xi,yi≤n) — description of the ii-th query.

Output

For each query from 11 to qq print the answer to this query. The answer to the ii-th query is the number written in the cell xi,yixi,yi (xixi is the row, yiyi is the column). Rows and columns are numbered from 11 to nn. Queries are numbered from 11 to qq in order of the input.

Examples

Input

4 5
1 1
4 4
4 3
3 2
2 4

Output

1
8
16
13
4

Input

5 4
2 1
4 2
3 3
3 4

Output

16
9
7
20

Note

Answers to the queries from examples are on the board in the picture from the problem statement.

题目大意:

    这题干已经没法看了,,格式都乱了,但是题意很简单。给一个n,然后先填x和y坐标和为偶数的,填满后再填奇数的。给q个询问,每个询问x和y坐标,输出这个坐标的值是多少。

解题报告:

   这题是真!MMP! 无聊!!首先看(x+y)是奇数还是偶数,然后xjb找规律,,,真的是无聊这题,,,大概就是先算前(x-1)行的,再看第x行的

AC代码:

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,q,x,y;
	cin>>n>>q;
	while(q--) {
		scanf("%lld%lld",&x,&y);
		ll ans = n*(x-1) + y + 1;
		if((x+y) % 2 == 1) {
			ans += n*n;
		}		
		cout << ans/2 << endl;
	}
	return 0 ;
}