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).
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.*;

public class C {
	static InputReader ir;
	static OutputPrinter op;
	static int t;
	static long x[];
	static long y[];

	public static void main(String[] args) throws IOException {
		ir = new InputReader();
		op = new OutputPrinter();
		t = ir.nextInt();
		x = new long[t];
		y = new long[t];
		for (int i = 0; i < t; i++) {
			x[i] = ir.nextInt();
			y[i] = ir.nextInt();
		}
		f();
	}

	public static void f() throws IOException {
		List<Long> as = new ArrayList<>();
		long cur = 3;
		long cumul = 5;
		while (cur <= 10e9) {
			as.add(cur);
			cur += cumul;
			cumul += 2;
		}
		for (int i = 0; i < t; i++) {
			long a = x[i];
			long b = y[i];
//			System.out.println("A is " + a + " and b is " + b);
			if (a <= 2) {
				op.writeln(0);
			} else {
				long result = 0;
				int curInd = 0;
				int gap = 1;
				int curB = 2;
				while (as.get(curInd) <= a) {
//					System.out.println("Looking at " + as.get(curInd));
					long aCount = (a - as.get(curInd)) / gap + 1;
					long bCount = b - curB + 1;
					if (bCount == 0) break;
//					System.out.println("Acount is "+ aCount + " and bCount is "+bCount);
					result += Math.min(aCount, bCount);
					curInd++;
					gap++;
					curB++;
				}
				op.writeln("" + result);
			}
		}
	}

	public static boolean p(List<Long> as, int ind, long a) {
		return as.get(ind) > a;
	}

}

class InputReader {
	public BufferedReader br;
	public StringTokenizer st;

	public InputReader() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	public int nextInt() throws IOException {
		if (st == null) {
			st = new StringTokenizer(br.readLine());
		}
		if (st.hasMoreElements()) {
			return Integer.parseInt(st.nextToken());
		} else {
			st = new StringTokenizer(br.readLine());
			return Integer.parseInt(st.nextToken());
		}
	}

	public double nextDouble() throws IOException {
		if (st == null) {
			st = new StringTokenizer(br.readLine());
		}
		if (st.hasMoreElements()) {
			return Double.parseDouble(st.nextToken());
		} else {
			st = new StringTokenizer(br.readLine());
			return Double.parseDouble(st.nextToken());
		}
	}

	public String nextToken() throws IOException {
		if (st == null) {
			st = new StringTokenizer(br.readLine());
		}
		if (st.hasMoreElements()) {
			return st.nextToken();
		} else {
			st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}
}

class OutputPrinter {
	public PrintWriter pw;

	public OutputPrinter() {
		pw = new PrintWriter(new OutputStreamWriter(System.out), true);
	}

	public void write(char[] buf) throws IOException {
		pw.write(buf);
		pw.flush();
	}

	public void writeln(char[] buf) throws IOException {
		write(buf);
		pw.write("\n");
		pw.flush();
	}

	public void write(String s) throws IOException {
		pw.write(s);
		pw.flush();
	}

	public void writeln(String s) throws IOException {
		write(s);
		pw.write("\n");
		pw.flush();
	}

	public void write(int t) throws IOException {
		pw.write(Integer.toString(t));
		pw.flush();
	}

	public void writeln(int t) throws IOException {
		write(t);
		pw.write("\n");
		pw.flush();
	}

	public void write(double d) throws IOException {
		pw.write(Double.toString(d));
		pw.flush();
	}

	public void writeln(double d) throws IOException {
		write(d);
		pw.write("\n");
		pw.flush();
	}

	public void writeln() {
		pw.write("\n");
		pw.flush();
	}
}