#C1872. Smallest Student Identifier

    ID: 45125 Type: Default 1000ms 256MiB

Smallest Student Identifier

Smallest Student Identifier

You are given n schools. In each school, student identifiers form an arithmetic sequence starting from the school's number with a common difference of n. For example, for school s, the identifiers are:

[ ; s,; s+n,; s+2n,; s+3n,; \dots ]

You need to answer q queries. Each query provides a school number s and an integer k. For each query, find the smallest student identifier from school s that is greater than or equal to k.

The answer for a query can be computed using the formula:

[ \text{answer} = s + \left\lceil \frac{k - s}{n} \right\rceil \times n, ]

where \(\lceil x \rceil\) denotes the ceiling of \(x\). If \(k \leq s\), the answer is simply \(s\).

inputFormat

The first line of the input contains two integers n and q separated by a space, where n is the number of schools and q is the number of queries. Each of the following q lines contains two integers s and k separated by a space. Here, s is the school number and k is the identifier from which to start searching.

outputFormat

For each query, output a single integer on a new line representing the smallest identifier from the specified school that is greater than or equal to k.

## sample
3 4
1 2
2 5
3 8
1 10
4

5 9 10

</p>