import std.algorithm, std.array, std.container, std.range; import std.numeric, std.math, std.bigint, std.bitmanip, std.random; import std.string, std.conv, std.stdio, std.typecons; void main() { auto n = readln.chomp.to!int; auto vi = iota(n) .map!(_ => readln.chomp) .map!(s => s.map!(c => c >= '0' && c <= '9' ? c - '0' : c - 'A' + 10).map!(to!long).array); auto r = vi.map!(v => toLong(v, v.reduce!(max) + 1)).reduce!(min); writeln(r); } long toLong(long[] v, long radix) { return iota(v.length).map!(i => v[i] * radix ^^ (v.length - i - 1)).sum; }