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.util.*;
import java.io.*;
import java.math.*;

public class Main {
	static PrintWriter pw = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while (t-- > 0) {
			int a = sc.nextInt(), b = sc.nextInt();
			long c = 0;
			if (b >= a)
				b = a - 1;
//			for (int i = 2; i <= b; i++) {
//				c += Math.min(a / (i + 1), i - 1);
//			}
//			pw.println(c);
//			for (int i = 2; i <= b; i++) {
//				c = 0;
//				for (int j = 1; j <= a; j++) {
//					if ((int) Math.floor(1.0 * j / i) == j % i) {
//						c++;
//					}
//				}
//				pw.print(c + " ");
//			}
//			pw.println();
			c = 0;
			int start = 0, end = b, x = -1;
			while (start <= end) {
				int mid = (start + end) / 2;
				if (mid - 1 <= a / (mid + 1)) {
					x = mid;
					start = mid + 1;
				} else {
					end = mid - 1;
				}
			}
//			pw.println(x);
			if (x == -1) {
				pw.println(0);
			} else {
				c += 1l * x * (x - 1) / 2;
				end = b;
				for (int i = 1; i < x; i++) {
					int ans = -1;
					start = x + 1;
					while (start <= end) {
						int mid = (start + end) / 2;
						if (a / (mid + 1) == i) {
							ans = mid;
							end = mid - 1;
						} else {
							start = mid + 1;
						}
					}
					if (ans == -1) {
						continue;
					}
//					pw.println(b + " " + ans);
					c += 1l * i * (b - ans + 1);
					b = ans - 1;
					end = ans - 1;
				}
				pw.println(c);
			}
		}
		pw.close();
	}

	public static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x == x && p.y == y;
			}
			return false;
		}

		public int hashCode() {
			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return Long.compare(this.y, other.y);
			}
			return Long.compare(this.x, other.x);
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}