h = Hash(Int64, Int32).new 3.upto(40) do |p| b = 2i64 while true u = b ** p break if u > 1_000_000_000_000i64 h[u] = p b += 1 end end read_line.to_i.times do n = read_line.to_i64 if h.has_key?(n) puts h[n] else sq = (n ** 0.5).to_i if (sq - 1) ** 2 == n || sq ** 2 == n || (sq + 1) ** 2 == n puts 2 else puts 1 end end end