ans = [] gets.to_i.times{ v = gets.chomp max = v.split('').max if max == '0' n = 2 elsif max <= '9' n = max.to_i + 1 else n = max.ord - 54 end ans.push(v.to_i(n)) } p ans.min