using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; public static class P { public static void Main() { int t = int.Parse(Console.ReadLine()); for (int i = 0; i < t; i++) { long n = int.Parse(Console.ReadLine()); while (n % 2 == 0) n /= 2; while (n % 5 == 0) n /= 5; long[] table = new long[10]; for (int j = 0; j < 10; j++) table[9 - (n * j) % 10] = n * j; int len = 0; long val = 0; do { val += table[val % 10]; val /= 10; len++; } while (val != 0); Console.WriteLine(len); } } }