eolymp
bolt
Try our new interface for solving problems
Problems

Queries About Numbers

Queries About Numbers

Etibar loves number theory very much. Now it is time to solve a new kind of problem.

There is given a natural number n. He has to answer q queries of the form t k. Here t is the type of query and k is the natural number.

If t = 1, He must find the number of natural numbers which is divisor of both n and k.

If t = 2, He must find the number of natural numbers which is divisor of n and is divisible by k.

If t = 3, He must find the number of natural numbers which is divisor of n and is not divisible by k.

Etibar can solve all these queries, but you will be hungry for night if this happens, because He will not have free time to do it. Therefore you compromise with him and decided that everyone must do his own job. You must program and our hero must do his own works.

Input

There will be two numbers in the first line: n and q (1n1012, 1q5 * 105). q lines follow with two numbers each: t and k (1t3, 1k1012).

Output

For each of the q lines you must output the result for corresponding query in separate line.

Time limit 1 second
Memory limit 64 MiB
Input example #1
12 6
1 6
1 14
2 4
2 3
3 12
3 14
Output example #1
4
2
2
3
5
6
Author Kamran Maharov
Source Local Contest #2 Qafqaz University by Mahammad Valiyev