import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    boolean ym = check(s.substring(0,2),s.substring(2,4));
    boolean my = check(s.substring(2,4),s.substring(0,2));
    if(ym){
      if(my){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("YYMM");
      }
    }else{
      if(my){
        System.out.println("MMYY");
      }else{
        System.out.println("NA");
      }
    }
  }
  public static boolean check(String y,String m){
    int yy = Integer.parseInt(y);
    int mm = Integer.parseInt(m);
    int judge = 0;
    if(yy>=0)judge++;
    if(mm>0&&mm<13)judge++;
    boolean ret = false;
    if(judge==2)ret = true;
    return ret;
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    boolean ym = check(s.substring(0,2),s.substring(2,4));
    boolean my = check(s.substring(2,4),s.substring(0,2));
    if(ym){
      if(my){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("YYMM");
      }
    }else{
      if(my){
        System.out.println("MMYY");
      }else{
        System.out.println("NA");
      }
    }
  }
  public static boolean check(String y,String m){
    int yy = Integer.parseInt(y);
    int mm = Integer.parseInt(m);
    int judge = 0;
    if(yy>=0)judge++;
    if(mm>0&&mm<13)judge++;
    boolean ret = false;
    if(judge==2)ret = true;
    return ret;
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    boolean ym = check(s.substring(0,2),s.substring(2,4));
    boolean my = check(s.substring(2,4),s.substring(0,2));
    if(ym){
      if(my){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("YYMM");
      }
    }else{
      if(my){
        System.out.println("MMYY");
      }else{
        System.out.println("NA");
      }
    }
  } main {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    boolean ym = check(s.substring(0,2),s.substring(2,4));
    boolean my = check(s.substring(2,4),s.substring(0,2));
    if(ym){
      if(my){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("YYMM");
      }
    }else{
      if(my){
        System.out.println("MMYY");
      }else{
        System.out.println("NA");
      }
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc boolean ym = check(s.substring(0,2),s.substring(2,4)); ym check(s.substring(0,2),s.substring(2,4)) check s.substring(0,2) s.substring s 0 2 s.substring(2,4) s.substring s 2 4 boolean my = check(s.substring(2,4),s.substring(0,2)); my check(s.substring(2,4),s.substring(0,2)) check s.substring(2,4) s.substring s 2 4 s.substring(0,2) s.substring s 0 2 if(ym){
      if(my){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("YYMM");
      }
    }else{
      if(my){
        System.out.println("MMYY");
      }else{
        System.out.println("NA");
      }
    } ym {
      if(my){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("YYMM");
      }
    } if(my){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("YYMM");
      } my {
        System.out.println("AMBIGUOUS");
      } System.out.println("AMBIGUOUS") System.out.println System.out System System.out "AMBIGUOUS" {
        System.out.println("YYMM");
      } System.out.println("YYMM") System.out.println System.out System System.out "YYMM" {
      if(my){
        System.out.println("MMYY");
      }else{
        System.out.println("NA");
      }
    } if(my){
        System.out.println("MMYY");
      }else{
        System.out.println("NA");
      } my {
        System.out.println("MMYY");
      } System.out.println("MMYY") System.out.println System.out System System.out "MMYY" {
        System.out.println("NA");
      } System.out.println("NA") System.out.println System.out System System.out "NA" String[] args args public static boolean check(String y,String m){
    int yy = Integer.parseInt(y);
    int mm = Integer.parseInt(m);
    int judge = 0;
    if(yy>=0)judge++;
    if(mm>0&&mm<13)judge++;
    boolean ret = false;
    if(judge==2)ret = true;
    return ret;
  } check {
    int yy = Integer.parseInt(y);
    int mm = Integer.parseInt(m);
    int judge = 0;
    if(yy>=0)judge++;
    if(mm>0&&mm<13)judge++;
    boolean ret = false;
    if(judge==2)ret = true;
    return ret;
  } int yy = Integer.parseInt(y); yy Integer.parseInt(y) Integer.parseInt Integer y int mm = Integer.parseInt(m); mm Integer.parseInt(m) Integer.parseInt Integer m int judge = 0; judge 0 if(yy>=0)judge++; yy>=0 yy 0 judge++ judge if(mm>0&&mm<13)judge++; mm>0&&mm<13 mm>0 mm 0 mm<13 mm 13 judge++ judge boolean ret = false; ret false if(judge==2)ret = true; judge==2 judge 2 ret = true ret true return ret; ret String y y String m m public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    boolean ym = check(s.substring(0,2),s.substring(2,4));
    boolean my = check(s.substring(2,4),s.substring(0,2));
    if(ym){
      if(my){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("YYMM");
      }
    }else{
      if(my){
        System.out.println("MMYY");
      }else{
        System.out.println("NA");
      }
    }
  }
  public static boolean check(String y,String m){
    int yy = Integer.parseInt(y);
    int mm = Integer.parseInt(m);
    int judge = 0;
    if(yy>=0)judge++;
    if(mm>0&&mm<13)judge++;
    boolean ret = false;
    if(judge==2)ret = true;
    return ret;
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    boolean ym = check(s.substring(0,2),s.substring(2,4));
    boolean my = check(s.substring(2,4),s.substring(0,2));
    if(ym){
      if(my){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("YYMM");
      }
    }else{
      if(my){
        System.out.println("MMYY");
      }else{
        System.out.println("NA");
      }
    }
  }
  public static boolean check(String y,String m){
    int yy = Integer.parseInt(y);
    int mm = Integer.parseInt(m);
    int judge = 0;
    if(yy>=0)judge++;
    if(mm>0&&mm<13)judge++;
    boolean ret = false;
    if(judge==2)ret = true;
    return ret;
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    boolean ym = check(s.substring(0,2),s.substring(2,4));
    boolean my = check(s.substring(2,4),s.substring(0,2));
    if(ym){
      if(my){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("YYMM");
      }
    }else{
      if(my){
        System.out.println("MMYY");
      }else{
        System.out.println("NA");
      }
    }
  }
  public static boolean check(String y,String m){
    int yy = Integer.parseInt(y);
    int mm = Integer.parseInt(m);
    int judge = 0;
    if(yy>=0)judge++;
    if(mm>0&&mm<13)judge++;
    boolean ret = false;
    if(judge==2)ret = true;
    return ret;
  }
}
