import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }
  
  String m[] = new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };

  void __solve(Scanner cin) {
	  String s = cin.next();
	  boolean f = false;
	  boolean t = false;
	  for( String M : m ) {
		  f |= s.substring(0, 2).equals(M);
		  t |= s.substring(2, 4).equals(M);
	  }
	  if( f && t ) {
		  System.out.println("AMBIGUOUS");
	  }
	  else if( f ) {
		  System.out.println("MMYY");
	  }
	  else if( t ) {
		  System.out.println("YYMM");
	  }
	  else {
		  System.out.println("NA");
	  }
  }

} import java.util.*; util.* java public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }
  
  String m[] = new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };

  void __solve(Scanner cin) {
	  String s = cin.next();
	  boolean f = false;
	  boolean t = false;
	  for( String M : m ) {
		  f |= s.substring(0, 2).equals(M);
		  t |= s.substring(2, 4).equals(M);
	  }
	  if( f && t ) {
		  System.out.println("AMBIGUOUS");
	  }
	  else if( f ) {
		  System.out.println("MMYY");
	  }
	  else if( t ) {
		  System.out.println("YYMM");
	  }
	  else {
		  System.out.println("NA");
	  }
  }

} Main String m[] = new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }; m new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" } public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  } main {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  } int rep = 1; rep 1 if( args.length > 0 ) { rep = Integer.parseInt(args[0]); } args.length > 0 args.length args args.length 0 { rep = Integer.parseInt(args[0]); } rep = Integer.parseInt(args[0]) rep Integer.parseInt(args[0]) Integer.parseInt Integer args[0] args 0 (new Main()).__solve(rep) (new Main()).__solve (new Main()) rep String args[] args void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  } __solve {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  } try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    } {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    } Scanner cin = new Scanner(System.in) Scanner cin = new Scanner(System.in) new Scanner(System.in) for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      } int i = 0; int i = 0; i 0 i < rep i rep ++i ++i i {
        __solve(cin);
      } {
        __solve(cin);
      } __solve(cin) __solve cin int rep rep void __solve(Scanner cin) {
	  String s = cin.next();
	  boolean f = false;
	  boolean t = false;
	  for( String M : m ) {
		  f |= s.substring(0, 2).equals(M);
		  t |= s.substring(2, 4).equals(M);
	  }
	  if( f && t ) {
		  System.out.println("AMBIGUOUS");
	  }
	  else if( f ) {
		  System.out.println("MMYY");
	  }
	  else if( t ) {
		  System.out.println("YYMM");
	  }
	  else {
		  System.out.println("NA");
	  }
  } __solve {
	  String s = cin.next();
	  boolean f = false;
	  boolean t = false;
	  for( String M : m ) {
		  f |= s.substring(0, 2).equals(M);
		  t |= s.substring(2, 4).equals(M);
	  }
	  if( f && t ) {
		  System.out.println("AMBIGUOUS");
	  }
	  else if( f ) {
		  System.out.println("MMYY");
	  }
	  else if( t ) {
		  System.out.println("YYMM");
	  }
	  else {
		  System.out.println("NA");
	  }
  } String s = cin.next(); s cin.next() cin.next cin boolean f = false; f false boolean t = false; t false for( String M : m ) {
		  f |= s.substring(0, 2).equals(M);
		  t |= s.substring(2, 4).equals(M);
	  } String M m {
		  f |= s.substring(0, 2).equals(M);
		  t |= s.substring(2, 4).equals(M);
	  } {
		  f |= s.substring(0, 2).equals(M);
		  t |= s.substring(2, 4).equals(M);
	  } f |= s.substring(0, 2).equals(M) f s.substring(0, 2).equals(M) s.substring(0, 2).equals s.substring(0, 2) s.substring s 0 2 M t |= s.substring(2, 4).equals(M) t s.substring(2, 4).equals(M) s.substring(2, 4).equals s.substring(2, 4) s.substring s 2 4 M if( f && t ) {
		  System.out.println("AMBIGUOUS");
	  }
	  else if( f ) {
		  System.out.println("MMYY");
	  }
	  else if( t ) {
		  System.out.println("YYMM");
	  }
	  else {
		  System.out.println("NA");
	  } f && t f t {
		  System.out.println("AMBIGUOUS");
	  } System.out.println("AMBIGUOUS") System.out.println System.out System System.out "AMBIGUOUS" if( f ) {
		  System.out.println("MMYY");
	  }
	  else if( t ) {
		  System.out.println("YYMM");
	  }
	  else {
		  System.out.println("NA");
	  } f {
		  System.out.println("MMYY");
	  } System.out.println("MMYY") System.out.println System.out System System.out "MMYY" if( t ) {
		  System.out.println("YYMM");
	  }
	  else {
		  System.out.println("NA");
	  } t {
		  System.out.println("YYMM");
	  } System.out.println("YYMM") System.out.println System.out System System.out "YYMM" {
		  System.out.println("NA");
	  } System.out.println("NA") System.out.println System.out System System.out "NA" Scanner cin cin public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }
  
  String m[] = new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };

  void __solve(Scanner cin) {
	  String s = cin.next();
	  boolean f = false;
	  boolean t = false;
	  for( String M : m ) {
		  f |= s.substring(0, 2).equals(M);
		  t |= s.substring(2, 4).equals(M);
	  }
	  if( f && t ) {
		  System.out.println("AMBIGUOUS");
	  }
	  else if( f ) {
		  System.out.println("MMYY");
	  }
	  else if( t ) {
		  System.out.println("YYMM");
	  }
	  else {
		  System.out.println("NA");
	  }
  }

} public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }
  
  String m[] = new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };

  void __solve(Scanner cin) {
	  String s = cin.next();
	  boolean f = false;
	  boolean t = false;
	  for( String M : m ) {
		  f |= s.substring(0, 2).equals(M);
		  t |= s.substring(2, 4).equals(M);
	  }
	  if( f && t ) {
		  System.out.println("AMBIGUOUS");
	  }
	  else if( f ) {
		  System.out.println("MMYY");
	  }
	  else if( t ) {
		  System.out.println("YYMM");
	  }
	  else {
		  System.out.println("NA");
	  }
  }

} Main
import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }
  
  String m[] = new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };

  void __solve(Scanner cin) {
	  String s = cin.next();
	  boolean f = false;
	  boolean t = false;
	  for( String M : m ) {
		  f |= s.substring(0, 2).equals(M);
		  t |= s.substring(2, 4).equals(M);
	  }
	  if( f && t ) {
		  System.out.println("AMBIGUOUS");
	  }
	  else if( f ) {
		  System.out.println("MMYY");
	  }
	  else if( t ) {
		  System.out.println("YYMM");
	  }
	  else {
		  System.out.println("NA");
	  }
  }

}
