Little Petya loves looking for numbers' divisors. One day Petya came across the following problem:

You are given n queries in the form "xi yi". For each query Petya should count how many divisors of number xi divide none of the numbers xi - yi, xi - yi + 1, ..., xi - 1. Help him.

Input

The first line contains an integer n (1 ≤ n ≤ 105). Each of the following n lines contain two space-separated integers xi and yi (1 ≤ xi ≤ 105, 0 ≤ yi ≤ i - 1, where i is the query's ordinal number; the numeration starts with 1). 

If yi = 0 for the query, then the answer to the query will be the number of divisors of the number xi. In this case you do not need to take the previous numbers x into consideration.

Output

For each query print the answer on a single line: the number of positive integers k such that <image>

Examples

Input

6
4 0
3 1
5 2
6 2
18 4
10000 3


Output

3
1
1
2
2
22

Note

Let's write out the divisors that give answers for the first 5 queries:

1) 1, 2, 4 

2) 3

3) 5

4) 2, 6

5) 9, 18
/**
 * Created by IntelliJ IDEA.
 * User: Taras_Brzezinsky
 * Date: 8/29/11
 * Time: 6:02 PM
 * To change this template use File | Settings | File Templates.
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.*;

public class TaskB extends Thread {
    public TaskB() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }

    private static final int lowerBound(int idx, int key) {
        int lo = -1;
        int hi = divisors[idx].size();
        while (hi - lo > 1) {
            int mid = (lo + hi) / 2;
            long midVal = divisors[idx].get(mid);
            if (midVal < key) {
                lo = mid;
            } else {
                hi = mid;
            }
        }
        return hi;
    }


    private void solve() throws Throwable {
        int n = nextInt();
        for (int query = 0; query < n; ++query) {
            long x = nextInt(), d;
            int total = 0, y = nextInt();
            if (y == 0) {
                for (d = 1; d * d < x; ++d) {
                    if (x % d == 0) {
                        total += 2;
                        divisors[(int) d].add(query);
                        divisors[(int) (x / d)].add(query);
                    }
                }
                if (d * d == x) {
                    ++total;
                    divisors[(int) d].add(query);
                }
            } else {
                int begin = query - y;
                for (d = 1; d * d < x; ++d) {
                    if (x % d == 0) {
                        if (divisors[(int) d].size() == 0 || lowerBound((int) d, begin) >= divisors[(int) d].size()) {
                            ++total;
                        }
                        divisors[(int) d].add(query);
                        if (divisors[(int) (x / d)].size() == 0 || lowerBound((int) (x / d), begin) >= divisors[(int) (x / d)].size() ) {
                            ++total;
                        }
                        divisors[(int) (x / d)].add(query);
                    }
                }
                if (d * d == x) {
                    if (divisors[(int) d].size() == 0 || lowerBound((int) d, begin) >= divisors[(int) d].size()) {
                        ++total;
                    }
                    divisors[(int) d].add(query);
                }
            }
            output.println(total);
        }

    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

    public static void main(String[] args) {
        new TaskB().start();
    }



    char nextChar() throws IOException {
        int c = input.read();
        while (c <= ' ') c = input.read();
        return (char) c;
    }

    int nextInt() throws IOException {
        int res = 0;
        int neg = 1;

        int c = 0;
        while (c != '-' && (c < '0' || c > '9')) c = input.read();
        if (c == '-') {
            c = '0';
            neg = -1;
        }
        while (c >= '0' && c <= '9') {
            res = res * 10 + c - '0';
            c = input.read();
        }
        return neg * res;
    }

    long nextLong() throws IOException {
        long res = 0;
        long neg = 1;
        int c = 0;
        while (c != '-' && (c < '0' || c > '9')) c = input.read();
        if (c == '-') {
            c = '0';
            neg = -1;
        }
        while (c >= '0' && c <= '9') {
            res = res * 10 + c - '0';
            c = input.read();
        }
        return neg * res;
    }

    double nextDouble() throws IOException {
        boolean up = false, sgn = false;
        double ret, base;
        int c = input.read();
        while ((c < '0' || c > '9') && c != '.' && c != '-') c = input.read();
        if (c == '-') {
            sgn = true;
            c = input.read();
        }
        ret = 0;
        base = 1;
        while ((c >= '0' && c <= '9') || c == '.') {
            if (up)
                base *= 10;
            if (c != '.')
                ret = ret * 10 + (c - '0');
            else
                up = true;
            c = input.read();
        }
        if (sgn)
            ret = -ret;
        return ret / base;
    }

    static final int MAX = (int) 1e5;
    static ArrayList<Integer> divisors[] = new ArrayList[MAX + 1];

    static {
        for (int i = 1; i <= MAX; ++i) {
            divisors[i] = new ArrayList<Integer>();
        }
    }


    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}