A pair of positive integers (a,b) is called special if ⌊ a/b ⌋ = a mod b. Here, ⌊ a/b ⌋ is the result of the integer division between a and b, while a mod b is its remainder.

You are given two integers x and y. Find the number of special pairs (a,b) such that 1≤ a ≤ x and 1 ≤ b ≤ y.

Input

The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases.

The only line of the description of each test case contains two integers x, y (1 ≤ x,y ≤ 10^9).

Output

For each test case print the answer on a single line.

Example

Input


9
3 4
2 100
4 3
50 3
12 4
69 420
12345 6789
123456 789
12345678 9


Output


1
0
2
3
5
141
53384
160909
36

Note

In the first test case, the only special pair is (3, 2).

In the second test case, there are no special pairs.

In the third test case, there are two special pairs: (3, 2) and (4, 3).
//package prac1500_1700;

import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;



public class Floor_Mod {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		InputReader in=new InputReader(System.in);    
        StringBuffer str=new StringBuffer();
		int t=in.nextInt();
		Solver p=new Solver();
		for(int i=0;i<t;i++) {
			long a=in.nextLong();
			long b=in.nextLong();
			p.solve(a, b);
		}
		
      
	}
	
	// class for solving the problem
static class Solver {
		
	
		public void solve(long a,long b) {
			long count=0;
			for(int k=1;k<=Math.sqrt(a);k++) {
				int x=k+1;
				long y=(long)(a-k)/k;
				long z=Math.min(y, b);
				if(z-x<0) {
					break;
				}
				else {
					count+=z-x+1;
				}
			}
			System.out.println(count);
		}
		
		
		
		
		// Function to take out all prime no less than n
		
		
		void all_prime_no_less_than_n(int n)
	    {
	        
	        boolean prime[] = new boolean[n + 1];
	        for (int i = 0; i <= n; i++)
	            prime[i] = true;
	 
	        for (int p = 2; p * p <= n; p++) 
	        {
	           
	            if (prime[p] == true) 
	            {
	             
	                for (int i = p * p; i <= n; i += p)
	                    prime[i] = false;
	            }
	        }
	 
	       
	        
	    }
		
	}

// class for taking fast input

static class InputReader{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new UnknownError();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new UnknownError();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int peek() {
        if (numChars == -1)
            return -1;
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                return -1;
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar];
    }

    public void skip(int x) {
        while (x-- > 0)
            read();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public String nextString() {
        return next();
    }

    public String next() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine() {
        StringBuffer buf = new StringBuffer();
        int c = read();
        while (c != '\n' && c != -1) {
            if (c != '\r')
                buf.appendCodePoint(c);
            c = read();
        }
        return buf.toString();
    }

    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, nextInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public boolean hasNext() {
        int value;
        while (isSpaceChar(value = peek()) && value != -1)
            read();
        return value != -1;
    }
    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
}





}
