open Printf open Scanf
open Array

let i c = int_of_char c - int_of_char '0'
let () = scanf " %s" @@ fun s ->
  let p,q,r,s = i s.[0], i s.[1], i s.[2], i s.[3] in
  let pqm =
    not (p*10+q >= 13 || p=0 && q=0) in
  let pqy =
    not (p=0 && q=0) in
  let rsm =
    not (r*10+s >= 13 || r=0 && s=0) in
  let rsy =
    not (r=0 && s=0) in
  (* printf "%d %d %d %d\n"
    p q r s
  ;
  printf "%b %b %b %b\n"
    pqm pqy rsm rsy; *)
  print_string @@
    if pqm && pqy && rsm && rsy then "AMBIGUOUS"
    else if pqm && rsy then "MMYY"
    else if pqy && rsm then "YYMM"
    else "NA"



