import std.stdio: readln, writeln; import std.conv: to; import std.string: chomp; const a = [1, 2, 5, 6, 5, 6, 7, 0, 1, 0]; void main() { auto t = readln.chomp.to!int; while(t--) { writeln(solve()); } } int solve() { const n = readln.chomp.to!long; return n == 0 ? 2 : a[n % 10]; }