| Author: | И. Блинов | Time limit: | 1 sec | |
| Input file: | Standard input | Memory limit: | 512 Mb | |
| Output file: | Standard output |
A badger is hiding in its complicated burrow, which is a long straight tunnel. The borrow is separated into N consecutive chambers, numbered 1 through N. The badger is very smart and sleeps in one of the chambers each night.
A team of two hunters learned about badger's habits and came up with a shrewd plan. Each night they will check the chambers with a certain step. In particular, on night i they check all the chambers with numbers divisible by Ai or Bi.
The badger will be caught if at least one hunter will check a chamber that it is sleeping in.
Your task is to find the number of safe chambers for the night i, i.e. chambers that the badger can sleep in without any of the hunters finding it.
The first line of the input contains two integers N and K — the number of chambers in the borrow and the number of nights.
The following K lines each contain two integers Ai, Bi — step size of each of the hunters.
Output K integers — numbers of safe chambers in the badger's borrow for each of the nights.
1 ≤ N ≤ 109, 1≤K≤104 1 ≤ Ai, Bi ≤ 109
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|