fn main() { let mut q = String::new(); std::io::stdin().read_line(&mut q).ok(); let q: usize = q.trim().parse().unwrap(); for _ in 0..q { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut itr = s.trim().split_ascii_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let k: usize = itr.next().unwrap().parse().unwrap(); if k == 1 { println!("{}", n - 1); continue; } else { let mut cnt: usize = 1; let mut p: usize = k; while p < n { p *= k; cnt += 1; } println!("{}", cnt); } } }