import java.util.*;
import java.io.*;

public class Main {
  static String[] result = new String[] {
    "YYMM", "MMYY", "AMBIGUOUS", "NA" 
  };
  
  static int type(int s) {
    if (0 <= s && s <= 99) {
      if (1 <= s && s <= 12) {
        return 1; // M
      }
      return 0; // Y
    }
    throw new RuntimeException();
  }

  public static void main(String ... args) throws Exception {
    int n = 0, k = 0;
    String s;
    try (BufferedReader isr = new BufferedReader(new InputStreamReader(System.in))) {
      String buf = isr.readLine();
      System.err.println(buf);
      /*
      String[] input = buf.split(" ");
      n = Integer.parseInt(input[0]);
      k = Integer.parseInt(input[1]);
      buf = isr.readLine();
      System.err.println(buf);
      */
      s = buf;
    }

    String s1 = s.substring(0,2);
    String s2 = s.substring(2,4);
    int l = type(Integer.parseInt(s1));
    int r = type(Integer.parseInt(s2));
    System.err.println(l);
    System.err.println(r);

    int res = 0;
    if ((l & r) == 1) {
      res = 2;
    } 
    if ((l | r) == 0) {
      res = 3;
    }
    if ((l ^ r) == 1) {
      if (l == 1) {
        res = 1;
      } else {
        res = 0;
      }
    }
    System.out.println(result[res]);
  }

} import java.util.*; util.* java import java.io.*; io.* java public class Main {
  static String[] result = new String[] {
    "YYMM", "MMYY", "AMBIGUOUS", "NA" 
  };
  
  static int type(int s) {
    if (0 <= s && s <= 99) {
      if (1 <= s && s <= 12) {
        return 1; // M
      }
      return 0; // Y
    }
    throw new RuntimeException();
  }

  public static void main(String ... args) throws Exception {
    int n = 0, k = 0;
    String s;
    try (BufferedReader isr = new BufferedReader(new InputStreamReader(System.in))) {
      String buf = isr.readLine();
      System.err.println(buf);
      /*
      String[] input = buf.split(" ");
      n = Integer.parseInt(input[0]);
      k = Integer.parseInt(input[1]);
      buf = isr.readLine();
      System.err.println(buf);
      */
      s = buf;
    }

    String s1 = s.substring(0,2);
    String s2 = s.substring(2,4);
    int l = type(Integer.parseInt(s1));
    int r = type(Integer.parseInt(s2));
    System.err.println(l);
    System.err.println(r);

    int res = 0;
    if ((l & r) == 1) {
      res = 2;
    } 
    if ((l | r) == 0) {
      res = 3;
    }
    if ((l ^ r) == 1) {
      if (l == 1) {
        res = 1;
      } else {
        res = 0;
      }
    }
    System.out.println(result[res]);
  }

} Main static String[] result = new String[] {
    "YYMM", "MMYY", "AMBIGUOUS", "NA" 
  }; result new String[] {
    "YYMM", "MMYY", "AMBIGUOUS", "NA" 
  } static int type(int s) {
    if (0 <= s && s <= 99) {
      if (1 <= s && s <= 12) {
        return 1; // M
      }
      return 0; // Y
    }
    throw new RuntimeException();
  } type {
    if (0 <= s && s <= 99) {
      if (1 <= s && s <= 12) {
        return 1; // M
      }
      return 0; // Y
    }
    throw new RuntimeException();
  } if (0 <= s && s <= 99) {
      if (1 <= s && s <= 12) {
        return 1; // M
      }
      return 0; // Y
    } 0 <= s && s <= 99 0 <= s 0 s s <= 99 s 99 {
      if (1 <= s && s <= 12) {
        return 1; // M
      }
      return 0; // Y
    } if (1 <= s && s <= 12) {
        return 1; // M
      } 1 <= s && s <= 12 1 <= s 1 s s <= 12 s 12 {
        return 1; // M
      } return 1; // M 1 return 0; // Y 0 throw new RuntimeException(); new RuntimeException() int s s public static void main(String ... args) throws Exception {
    int n = 0, k = 0;
    String s;
    try (BufferedReader isr = new BufferedReader(new InputStreamReader(System.in))) {
      String buf = isr.readLine();
      System.err.println(buf);
      /*
      String[] input = buf.split(" ");
      n = Integer.parseInt(input[0]);
      k = Integer.parseInt(input[1]);
      buf = isr.readLine();
      System.err.println(buf);
      */
      s = buf;
    }

    String s1 = s.substring(0,2);
    String s2 = s.substring(2,4);
    int l = type(Integer.parseInt(s1));
    int r = type(Integer.parseInt(s2));
    System.err.println(l);
    System.err.println(r);

    int res = 0;
    if ((l & r) == 1) {
      res = 2;
    } 
    if ((l | r) == 0) {
      res = 3;
    }
    if ((l ^ r) == 1) {
      if (l == 1) {
        res = 1;
      } else {
        res = 0;
      }
    }
    System.out.println(result[res]);
  } main {
    int n = 0, k = 0;
    String s;
    try (BufferedReader isr = new BufferedReader(new InputStreamReader(System.in))) {
      String buf = isr.readLine();
      System.err.println(buf);
      /*
      String[] input = buf.split(" ");
      n = Integer.parseInt(input[0]);
      k = Integer.parseInt(input[1]);
      buf = isr.readLine();
      System.err.println(buf);
      */
      s = buf;
    }

    String s1 = s.substring(0,2);
    String s2 = s.substring(2,4);
    int l = type(Integer.parseInt(s1));
    int r = type(Integer.parseInt(s2));
    System.err.println(l);
    System.err.println(r);

    int res = 0;
    if ((l & r) == 1) {
      res = 2;
    } 
    if ((l | r) == 0) {
      res = 3;
    }
    if ((l ^ r) == 1) {
      if (l == 1) {
        res = 1;
      } else {
        res = 0;
      }
    }
    System.out.println(result[res]);
  } int n = 0 n 0 k = 0; k 0 String s; s try (BufferedReader isr = new BufferedReader(new InputStreamReader(System.in))) {
      String buf = isr.readLine();
      System.err.println(buf);
      /*
      String[] input = buf.split(" ");
      n = Integer.parseInt(input[0]);
      k = Integer.parseInt(input[1]);
      buf = isr.readLine();
      System.err.println(buf);
      */
      s = buf;
    } {
      String buf = isr.readLine();
      System.err.println(buf);
      /*
      String[] input = buf.split(" ");
      n = Integer.parseInt(input[0]);
      k = Integer.parseInt(input[1]);
      buf = isr.readLine();
      System.err.println(buf);
      */
      s = buf;
    } BufferedReader isr = new BufferedReader(new InputStreamReader(System.in)) BufferedReader isr = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String buf = isr.readLine(); buf isr.readLine() isr.readLine isr System.err.println(buf) System.err.println System.err System System.err buf s = buf s buf String s1 = s.substring(0,2); s1 s.substring(0,2) s.substring s 0 2 String s2 = s.substring(2,4); s2 s.substring(2,4) s.substring s 2 4 int l = type(Integer.parseInt(s1)); l type(Integer.parseInt(s1)) type Integer.parseInt(s1) Integer.parseInt Integer s1 int r = type(Integer.parseInt(s2)); r type(Integer.parseInt(s2)) type Integer.parseInt(s2) Integer.parseInt Integer s2 System.err.println(l) System.err.println System.err System System.err l System.err.println(r) System.err.println System.err System System.err r int res = 0; res 0 if ((l & r) == 1) {
      res = 2;
    } (l & r) == 1 (l & r) l r 1 {
      res = 2;
    } res = 2 res 2 if ((l | r) == 0) {
      res = 3;
    } (l | r) == 0 (l | r) l r 0 {
      res = 3;
    } res = 3 res 3 if ((l ^ r) == 1) {
      if (l == 1) {
        res = 1;
      } else {
        res = 0;
      }
    } (l ^ r) == 1 (l ^ r) l r 1 {
      if (l == 1) {
        res = 1;
      } else {
        res = 0;
      }
    } if (l == 1) {
        res = 1;
      } else {
        res = 0;
      } l == 1 l 1 {
        res = 1;
      } res = 1 res 1 {
        res = 0;
      } res = 0 res 0 System.out.println(result[res]) System.out.println System.out System System.out result[res] result res String ... args args public class Main {
  static String[] result = new String[] {
    "YYMM", "MMYY", "AMBIGUOUS", "NA" 
  };
  
  static int type(int s) {
    if (0 <= s && s <= 99) {
      if (1 <= s && s <= 12) {
        return 1; // M
      }
      return 0; // Y
    }
    throw new RuntimeException();
  }

  public static void main(String ... args) throws Exception {
    int n = 0, k = 0;
    String s;
    try (BufferedReader isr = new BufferedReader(new InputStreamReader(System.in))) {
      String buf = isr.readLine();
      System.err.println(buf);
      /*
      String[] input = buf.split(" ");
      n = Integer.parseInt(input[0]);
      k = Integer.parseInt(input[1]);
      buf = isr.readLine();
      System.err.println(buf);
      */
      s = buf;
    }

    String s1 = s.substring(0,2);
    String s2 = s.substring(2,4);
    int l = type(Integer.parseInt(s1));
    int r = type(Integer.parseInt(s2));
    System.err.println(l);
    System.err.println(r);

    int res = 0;
    if ((l & r) == 1) {
      res = 2;
    } 
    if ((l | r) == 0) {
      res = 3;
    }
    if ((l ^ r) == 1) {
      if (l == 1) {
        res = 1;
      } else {
        res = 0;
      }
    }
    System.out.println(result[res]);
  }

} public class Main {
  static String[] result = new String[] {
    "YYMM", "MMYY", "AMBIGUOUS", "NA" 
  };
  
  static int type(int s) {
    if (0 <= s && s <= 99) {
      if (1 <= s && s <= 12) {
        return 1; // M
      }
      return 0; // Y
    }
    throw new RuntimeException();
  }

  public static void main(String ... args) throws Exception {
    int n = 0, k = 0;
    String s;
    try (BufferedReader isr = new BufferedReader(new InputStreamReader(System.in))) {
      String buf = isr.readLine();
      System.err.println(buf);
      /*
      String[] input = buf.split(" ");
      n = Integer.parseInt(input[0]);
      k = Integer.parseInt(input[1]);
      buf = isr.readLine();
      System.err.println(buf);
      */
      s = buf;
    }

    String s1 = s.substring(0,2);
    String s2 = s.substring(2,4);
    int l = type(Integer.parseInt(s1));
    int r = type(Integer.parseInt(s2));
    System.err.println(l);
    System.err.println(r);

    int res = 0;
    if ((l & r) == 1) {
      res = 2;
    } 
    if ((l | r) == 0) {
      res = 3;
    }
    if ((l ^ r) == 1) {
      if (l == 1) {
        res = 1;
      } else {
        res = 0;
      }
    }
    System.out.println(result[res]);
  }

} Main
import java.util.*;
import java.io.*;

public class Main {
  static String[] result = new String[] {
    "YYMM", "MMYY", "AMBIGUOUS", "NA" 
  };
  
  static int type(int s) {
    if (0 <= s && s <= 99) {
      if (1 <= s && s <= 12) {
        return 1; // M
      }
      return 0; // Y
    }
    throw new RuntimeException();
  }

  public static void main(String ... args) throws Exception {
    int n = 0, k = 0;
    String s;
    try (BufferedReader isr = new BufferedReader(new InputStreamReader(System.in))) {
      String buf = isr.readLine();
      System.err.println(buf);
      /*
      String[] input = buf.split(" ");
      n = Integer.parseInt(input[0]);
      k = Integer.parseInt(input[1]);
      buf = isr.readLine();
      System.err.println(buf);
      */
      s = buf;
    }

    String s1 = s.substring(0,2);
    String s2 = s.substring(2,4);
    int l = type(Integer.parseInt(s1));
    int r = type(Integer.parseInt(s2));
    System.err.println(l);
    System.err.println(r);

    int res = 0;
    if ((l & r) == 1) {
      res = 2;
    } 
    if ((l | r) == 0) {
      res = 3;
    }
    if ((l ^ r) == 1) {
      if (l == 1) {
        res = 1;
      } else {
        res = 0;
      }
    }
    System.out.println(result[res]);
  }

}
