import java.sql.Date;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		String cnt = "20";
		String day = "01";

		Scanner sc1 = new Scanner(System.in);

		String s = sc1.next();

		String str1 = s.substring(0, 2);
		String str2 = s.substring(2, 4);

		//YYMM
		String date1 = cnt + str1 + "-" + str2 + "-" + day;
		//MMYY
		String date2 = cnt + str2 + "-" + str1 + "-" + day;

		//System.out.println(date1);
		//System.out.println(date2);

		boolean flg1 = true;
		boolean flg2 = true;

		try {
			Date.valueOf(date1);
		}
		catch(IllegalArgumentException e) {
			flg1 = false;
		}

		try {
			Date.valueOf(date2);
		}
		catch(IllegalArgumentException e) {
			flg2 = false;
		}

		if (flg1 && flg2) {
			System.out.println("AMBIGUOUS");
		}
		else if (flg1) {
			System.out.println("YYMM");
		}
		else if (flg2) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		}

		sc1.close();

	}

} import java.sql.Date; Date java.sql import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		String cnt = "20";
		String day = "01";

		Scanner sc1 = new Scanner(System.in);

		String s = sc1.next();

		String str1 = s.substring(0, 2);
		String str2 = s.substring(2, 4);

		//YYMM
		String date1 = cnt + str1 + "-" + str2 + "-" + day;
		//MMYY
		String date2 = cnt + str2 + "-" + str1 + "-" + day;

		//System.out.println(date1);
		//System.out.println(date2);

		boolean flg1 = true;
		boolean flg2 = true;

		try {
			Date.valueOf(date1);
		}
		catch(IllegalArgumentException e) {
			flg1 = false;
		}

		try {
			Date.valueOf(date2);
		}
		catch(IllegalArgumentException e) {
			flg2 = false;
		}

		if (flg1 && flg2) {
			System.out.println("AMBIGUOUS");
		}
		else if (flg1) {
			System.out.println("YYMM");
		}
		else if (flg2) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		}

		sc1.close();

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		String cnt = "20";
		String day = "01";

		Scanner sc1 = new Scanner(System.in);

		String s = sc1.next();

		String str1 = s.substring(0, 2);
		String str2 = s.substring(2, 4);

		//YYMM
		String date1 = cnt + str1 + "-" + str2 + "-" + day;
		//MMYY
		String date2 = cnt + str2 + "-" + str1 + "-" + day;

		//System.out.println(date1);
		//System.out.println(date2);

		boolean flg1 = true;
		boolean flg2 = true;

		try {
			Date.valueOf(date1);
		}
		catch(IllegalArgumentException e) {
			flg1 = false;
		}

		try {
			Date.valueOf(date2);
		}
		catch(IllegalArgumentException e) {
			flg2 = false;
		}

		if (flg1 && flg2) {
			System.out.println("AMBIGUOUS");
		}
		else if (flg1) {
			System.out.println("YYMM");
		}
		else if (flg2) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		}

		sc1.close();

	} main {
		// TODO 自動生成されたメソッド・スタブ

		String cnt = "20";
		String day = "01";

		Scanner sc1 = new Scanner(System.in);

		String s = sc1.next();

		String str1 = s.substring(0, 2);
		String str2 = s.substring(2, 4);

		//YYMM
		String date1 = cnt + str1 + "-" + str2 + "-" + day;
		//MMYY
		String date2 = cnt + str2 + "-" + str1 + "-" + day;

		//System.out.println(date1);
		//System.out.println(date2);

		boolean flg1 = true;
		boolean flg2 = true;

		try {
			Date.valueOf(date1);
		}
		catch(IllegalArgumentException e) {
			flg1 = false;
		}

		try {
			Date.valueOf(date2);
		}
		catch(IllegalArgumentException e) {
			flg2 = false;
		}

		if (flg1 && flg2) {
			System.out.println("AMBIGUOUS");
		}
		else if (flg1) {
			System.out.println("YYMM");
		}
		else if (flg2) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		}

		sc1.close();

	} String cnt = "20"; cnt "20" String day = "01"; day "01" Scanner sc1 = new Scanner(System.in); sc1 new Scanner(System.in) String s = sc1.next(); s sc1.next() sc1.next sc1 String str1 = s.substring(0, 2); str1 s.substring(0, 2) s.substring s 0 2 String str2 = s.substring(2, 4); str2 s.substring(2, 4) s.substring s 2 4 String date1 = cnt + str1 + "-" + str2 + "-" + day; date1 cnt + str1 + "-" + str2 + "-" + day "-" str2 "-" cnt + str1 + "-" + str2 + "-" + day cnt str1 "-" str2 "-" day String date2 = cnt + str2 + "-" + str1 + "-" + day; date2 cnt + str2 + "-" + str1 + "-" + day "-" str1 "-" cnt + str2 + "-" + str1 + "-" + day cnt str2 "-" str1 "-" day boolean flg1 = true; flg1 true boolean flg2 = true; flg2 true try {
			Date.valueOf(date1);
		}
		catch(IllegalArgumentException e) {
			flg1 = false;
		} catch(IllegalArgumentException e) {
			flg1 = false;
		} IllegalArgumentException e {
			flg1 = false;
		} flg1 = false flg1 false {
			Date.valueOf(date1);
		} Date.valueOf(date1) Date.valueOf Date date1 try {
			Date.valueOf(date2);
		}
		catch(IllegalArgumentException e) {
			flg2 = false;
		} catch(IllegalArgumentException e) {
			flg2 = false;
		} IllegalArgumentException e {
			flg2 = false;
		} flg2 = false flg2 false {
			Date.valueOf(date2);
		} Date.valueOf(date2) Date.valueOf Date date2 if (flg1 && flg2) {
			System.out.println("AMBIGUOUS");
		}
		else if (flg1) {
			System.out.println("YYMM");
		}
		else if (flg2) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		} flg1 && flg2 flg1 flg2 {
			System.out.println("AMBIGUOUS");
		} System.out.println("AMBIGUOUS") System.out.println System.out System System.out "AMBIGUOUS" if (flg1) {
			System.out.println("YYMM");
		}
		else if (flg2) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		} flg1 {
			System.out.println("YYMM");
		} System.out.println("YYMM") System.out.println System.out System System.out "YYMM" if (flg2) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		} flg2 {
			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" sc1.close() sc1.close sc1 String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		String cnt = "20";
		String day = "01";

		Scanner sc1 = new Scanner(System.in);

		String s = sc1.next();

		String str1 = s.substring(0, 2);
		String str2 = s.substring(2, 4);

		//YYMM
		String date1 = cnt + str1 + "-" + str2 + "-" + day;
		//MMYY
		String date2 = cnt + str2 + "-" + str1 + "-" + day;

		//System.out.println(date1);
		//System.out.println(date2);

		boolean flg1 = true;
		boolean flg2 = true;

		try {
			Date.valueOf(date1);
		}
		catch(IllegalArgumentException e) {
			flg1 = false;
		}

		try {
			Date.valueOf(date2);
		}
		catch(IllegalArgumentException e) {
			flg2 = false;
		}

		if (flg1 && flg2) {
			System.out.println("AMBIGUOUS");
		}
		else if (flg1) {
			System.out.println("YYMM");
		}
		else if (flg2) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		}

		sc1.close();

	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		String cnt = "20";
		String day = "01";

		Scanner sc1 = new Scanner(System.in);

		String s = sc1.next();

		String str1 = s.substring(0, 2);
		String str2 = s.substring(2, 4);

		//YYMM
		String date1 = cnt + str1 + "-" + str2 + "-" + day;
		//MMYY
		String date2 = cnt + str2 + "-" + str1 + "-" + day;

		//System.out.println(date1);
		//System.out.println(date2);

		boolean flg1 = true;
		boolean flg2 = true;

		try {
			Date.valueOf(date1);
		}
		catch(IllegalArgumentException e) {
			flg1 = false;
		}

		try {
			Date.valueOf(date2);
		}
		catch(IllegalArgumentException e) {
			flg2 = false;
		}

		if (flg1 && flg2) {
			System.out.println("AMBIGUOUS");
		}
		else if (flg1) {
			System.out.println("YYMM");
		}
		else if (flg2) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		}

		sc1.close();

	}

} Main
import java.sql.Date;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		String cnt = "20";
		String day = "01";

		Scanner sc1 = new Scanner(System.in);

		String s = sc1.next();

		String str1 = s.substring(0, 2);
		String str2 = s.substring(2, 4);

		//YYMM
		String date1 = cnt + str1 + "-" + str2 + "-" + day;
		//MMYY
		String date2 = cnt + str2 + "-" + str1 + "-" + day;

		//System.out.println(date1);
		//System.out.println(date2);

		boolean flg1 = true;
		boolean flg2 = true;

		try {
			Date.valueOf(date1);
		}
		catch(IllegalArgumentException e) {
			flg1 = false;
		}

		try {
			Date.valueOf(date2);
		}
		catch(IllegalArgumentException e) {
			flg2 = false;
		}

		if (flg1 && flg2) {
			System.out.println("AMBIGUOUS");
		}
		else if (flg1) {
			System.out.println("YYMM");
		}
		else if (flg2) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		}

		sc1.close();

	}

}