s1, s2 = gets.chomp.scan(/.{1,2}/).map(&:to_i)

def distinguish(a, b)
  if a!=0 and b!=0 and b<=12
    true
  else
    false
  end
end

ym = distinguish(s1, s2)
my = distinguish(s2, s1)

if ym && my
  puts "AMBIGUOUS"
elsif ym
  puts "YYMM"
elsif my
  puts "MMYY"
else
  puts "NA"
end
