T = [*?a..?z, ?., ??, ?!, ?\ ].each_slice(5).to_a.transpose.freeze
$<.each do |l|
  l.chomp!
  if l.size.odd?
    puts 'NA'
    next
  end
  f, rs = true, []
  l.each_char.each_slice(2) do |as|
    i, j = as.map {|a| a.to_i - 1 }
    if j <= T.size && i <= T.first.size
      rs << T[j][i]
    else
      f = false
      break
    end
  end
  puts f ? rs.join : 'NA'
end