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
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author dipankar12
 */
import java.io.*;
import java.util.*;
public class r85b {
    public static void main(String args[])
    {
        fastio in=new fastio(System.in);
        PrintWriter pw=new PrintWriter(System.out);

        int n=in.nextInt();
        int ar[][]=new int[n+1][2];
        for(int i=1;i<=n;i++)
        {
            ar[i][0]=in.nextInt();
            ar[i][1]=in.nextInt();
        }
        
        int fact[][]=new int[n+1][318];
        TreeSet<Integer> prime[]=new TreeSet[100001];
        for(int i=0;i<100001;i++)
            prime[i]=new TreeSet<Integer>();
        
        r85b ob=new r85b();
        
        for(int i=1;i<=n;i++)
        {
            int x=ar[i][0];
            for(int j=1;j<(int)Math.sqrt(x)+1;j++)
                if(x%j==0)
                {
                    fact[i][j]++;
                    if(x/j>317)
                        prime[x/j].add(i);
                    else
                        if(x/j!=j)
                            fact[i][x/j]++;
                }
            
            for(int j=0;j<318;j++)
                fact[i][j]+=fact[i-1][j];
        }
        
        int ans[]=new int[n+1];
        for(int i=1;i<=n;i++)
        {
            int x=ar[i][0];
            int y=ar[i][1];
            
            if(y==0)
            {
                for(int j=1;j<(int)Math.sqrt(x)+1;j++)
                {
                    if(x%j==0)
                        ans[i]+=2;
                    if(x%j==0&&x/j*x/j==x)
                        ans[i]--;
                }
            }
            else
            {
                for(int j=1;j<(int)Math.sqrt(x)+1;j++)
                {
                    if(x%j==0)
                    {
                        if(fact[i][j]-fact[i-y-1][j]==1&&j!=1)
                            ans[i]++;
                        if(i==1&&j==1)
                            ans[i]++;
                        if(x/j>317)
                        {
                            int p=-1,q=-1;
                            if(prime[x/j].lower(i)!=null)
                                p=prime[x/j].lower(i);
                            if(prime[x/j].higher(i-y-1)!=null)
                                q=prime[x/j].higher(i-y-1);

                            if(p==-1)
                                ans[i]++;
                            if(p!=-1&&q!=-1&&p<q)
                                ans[i]++;
                        }
                        else
                            if(fact[i][x/j]-fact[i-y-1][x/j]==1&&x/j!=j)
                                ans[i]++;

                        //if(y==0&&j*j==x)
                            //ans[i]++;
                    }
                }
            }
        }
        
        //pw.println("fact");
        //for(int i=0;i<=n;i++)
        //{
            //for(int j=0;j<20;j++)
                //pw.print(fact[i][j]+" ");
            //pw.println();
        //}
        for(int i=1;i<=n;i++)
            pw.println(ans[i]);
        pw.close();
    }

    static class fastio {
     
            private final InputStream stream;
            private final byte[] buf = new byte[8192];
            private int cchar, snchar;
            private SpaceCharFilter filter;
     
            public fastio(InputStream stream) {
                this.stream = stream;
            }
     
            public int nxt() {
                if (snchar == -1)
                    throw new InputMismatchException();
                if (cchar >= snchar) {
                    cchar = 0;
                    try {
                        snchar = stream.read(buf);
                    } catch (IOException e) {
                        throw new InputMismatchException();
                    }
                    if (snchar <= 0)
                        return -1;
                }
                return buf[cchar++];
            }
     
            public int nextInt() {
                int c = nxt();
                while (isSpaceChar(c)) {
                    c = nxt();
                }
                int sgn = 1;
                if (c == '-') {
                    sgn = -1;
                    c = nxt();
                }
                int res = 0;
                do {
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    res *= 10;
                    res += c - '0';
                    c = nxt();
                } while (!isSpaceChar(c));
                return res * sgn;
            }
     
            public long nextLong() {
                int c = nxt();
                while (isSpaceChar(c)) {
                    c = nxt();
                }
                int sgn = 1;
                if (c == '-') {
                    sgn = -1;
                    c = nxt();
                }
                long res = 0;
                do {
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    res *= 10;
                    res += c - '0';
                    c = nxt();
                } while (!isSpaceChar(c));
                return res * sgn;
            }
     
            public int[] nextIntArray(int n) {
                int a[] = new int[n];
                for (int i = 0; i < n; i++) {
                    a[i] = nextInt();
                }
                return a;
            }
     
            public String readString() {
                int c = nxt();
                while (isSpaceChar(c)) {
                    c = nxt();
                }
                StringBuilder res = new StringBuilder();
                do {
                    res.appendCodePoint(c);
                    c = nxt();
                } while (!isSpaceChar(c));
                return res.toString();
            }
     
            public String nextLine() {
                int c = nxt();
                while (isSpaceChar(c))
                    c = nxt();
                StringBuilder res = new StringBuilder();
                do {
                    res.appendCodePoint(c);
                    c = nxt();
                } while (!isEndOfLine(c));
                return res.toString();
            }
     
            public boolean isSpaceChar(int c) {
                if (filter != null)
                    return filter.isSpaceChar(c);
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
            }
     
            private boolean isEndOfLine(int c) {
                return c == '\n' || c == '\r' || c == -1;
            }
     
            public interface SpaceCharFilter {
                public boolean isSpaceChar(int ch);
            }
        }
    

}
