from math import modf from sys import stdin def main(): input = lambda: stdin.readline()[:-1] Q = int(input()) NK = [tuple(map(int, input().split())) for _ in [0] * Q] for n, k in NK: if k == 1: print(n - 1) else: m, d = modf(n ** (1 / k)) m = round2(m, 2) print(int(d + 1)) if m else print(int(d)) def round2(n, d=0): p = 10 ** d return (n * p * 2 + 1) // 2 / p main()