using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var ans = new long[t]; for (var u = 0; u < t; ++u) { var c = NList; var (a, b) = (c[0], c[1]); var ng = 0L; var ok = (long)Math.Sqrt(a) + (long)Math.Sqrt(b) + 100; while (ok - ng > 1) { var mid = (ok + ng) / 2; if (mid * mid * mid * mid - 2 * mid * mid * a - 2 * mid * mid * b + a * a + b * b - 2 * a * b > 0) ok = mid; else ng = mid; } ans[u] = ok; } WriteLine(string.Join("\n", ans)); } }