import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0];
    auto Q = s[1];

    while (Q--) {
        s = readln.split.map!(to!long);
        auto r = s[0];
        auto c = s[1];
        if ((r + c) % 2 == 0) {
            long odd = r / 2;
            long even = r - 1 - odd;
            long n = odd * (N / 2 + N % 2) + even * (N / 2);
            writeln(n + (c - 1) / 2 + 1);
        } else {
            long odd = r / 2;
            long even = r - 1 - odd;
            long n = odd * (N / 2) + even * (N / 2 + N % 2);
            n += N * N / 2 + N % 2;
            writeln(n + (c - 1) / 2 + 1);
        }
    }
}
