시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 322 56 47 22.816%

문제

수학 나라에 전쟁이 일어났다. 팩토리얼 진영과 거듭제곱 진영은 누가 수학 나라를 지배할 것인지 결정하기 위해 싸우고 있다.

팩토리얼 진영의 유명한 장군 n은 자기 자신을 팩토리얼 계산을 하면서 훈련을 하고 있고, 거듭제곱진영의 제독 k는 자기 자신에 i제곱을 하기 위해 i를 만들고 있었다.

드디어 오늘은 n과 k가 싸우는 날이다. k는 n을 나누어서 작은 수로 만들어 버리기 위해서 몇 년동안 훈련을 진행하고 있었다.

이제 k는 n을 나누려고 한다. 훈련을 통해서 모두 성장했으므로, n!와 ki와 싸우는 것이다.

이때, n!을 ki로 나눌 수 있는 가장 큰 i를 찾는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 T가 주어진다. (1 ≤ T ≤ 100) 다음 T개의 줄에는 n과 k가 공백으로 구분되어 주어진다. (2 ≤ n ≤ 1018, 2 ≤  k ≤ 1012)

출력

각각의 테스트 케이스에 대해서, 가장 큰 i를 한 줄에 하나씩 출력한다.

예제 입력 1

2
5 2
10 10

예제 출력 1

3
2
W3sicHJvYmxlbV9pZCI6IjM5NjQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzMjlcdWQxYTBcdWI5YWNcdWM1YmNcdWFjZmMgXHVhYzcwXHViNGVkXHVjODFjXHVhY2YxIiwiZGVzY3JpcHRpb24iOiI8cD5cclxuXHRcdWMyMThcdWQ1NTkgXHViMDk4XHViNzdjXHVjNWQwIFx1YzgwNFx1YzdjMVx1Yzc3NCBcdWM3N2NcdWM1YjRcdWIwYWNcdWIyZTQuIFx1ZDMyOVx1ZDFhMFx1YjlhY1x1YzViYyBcdWM5YzRcdWM2MDFcdWFjZmMgXHVhYzcwXHViNGVkXHVjODFjXHVhY2YxIFx1YzljNFx1YzYwMVx1Yzc0MCBcdWIyMDRcdWFjMDAgXHVjMjE4XHVkNTU5IFx1Yj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