using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Console; using static System.Math; namespace CP { class Atria { static void Main(string[] args) { int q = int.Parse(ReadLine()); for (int i = 0; i < q; i++) { long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray(); if (s[1] == 1) { WriteLine(s[0]-1); continue; } long ans = 0; long now = 1; while (s[0] - now > 0) { now *= s[1]; ans++; } WriteLine(ans); } } } }