import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        ArrayList<String> input = new ArrayList<String>();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            input.add(s);
        }
        sc.close();

        String output = "";

        String f = input.get(0).substring(0, 2);
        String b = input.get(0).substring(2);

        if (ym(f).equals(ym(b)) && ym(f).equals("MM")) {
            output = "AMBIGUOUS";
        } else if (ym(f).equals(ym(b)) && ym(f).equals("YY")) {
            output = "NA";
        } else if (ym(f).equals("MM")) {
            output = "MMYY";
        } else if (ym(f).equals("YY")) {
            output = "YYMM";
        }

        System.out.println(output);
    }

    private static String ym(String str) {
        String s;
        int a = Integer.parseInt(str);
        if (a >= 1 && a <= 12) {
            s = "MM";
        } else {
            s = "YY";
        }
        return s;
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        ArrayList<String> input = new ArrayList<String>();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            input.add(s);
        }
        sc.close();

        String output = "";

        String f = input.get(0).substring(0, 2);
        String b = input.get(0).substring(2);

        if (ym(f).equals(ym(b)) && ym(f).equals("MM")) {
            output = "AMBIGUOUS";
        } else if (ym(f).equals(ym(b)) && ym(f).equals("YY")) {
            output = "NA";
        } else if (ym(f).equals("MM")) {
            output = "MMYY";
        } else if (ym(f).equals("YY")) {
            output = "YYMM";
        }

        System.out.println(output);
    }

    private static String ym(String str) {
        String s;
        int a = Integer.parseInt(str);
        if (a >= 1 && a <= 12) {
            s = "MM";
        } else {
            s = "YY";
        }
        return s;
    }
} Main public static void main(String[] args) {
        ArrayList<String> input = new ArrayList<String>();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            input.add(s);
        }
        sc.close();

        String output = "";

        String f = input.get(0).substring(0, 2);
        String b = input.get(0).substring(2);

        if (ym(f).equals(ym(b)) && ym(f).equals("MM")) {
            output = "AMBIGUOUS";
        } else if (ym(f).equals(ym(b)) && ym(f).equals("YY")) {
            output = "NA";
        } else if (ym(f).equals("MM")) {
            output = "MMYY";
        } else if (ym(f).equals("YY")) {
            output = "YYMM";
        }

        System.out.println(output);
    } main {
        ArrayList<String> input = new ArrayList<String>();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            input.add(s);
        }
        sc.close();

        String output = "";

        String f = input.get(0).substring(0, 2);
        String b = input.get(0).substring(2);

        if (ym(f).equals(ym(b)) && ym(f).equals("MM")) {
            output = "AMBIGUOUS";
        } else if (ym(f).equals(ym(b)) && ym(f).equals("YY")) {
            output = "NA";
        } else if (ym(f).equals("MM")) {
            output = "MMYY";
        } else if (ym(f).equals("YY")) {
            output = "YYMM";
        }

        System.out.println(output);
    } ArrayList<String> input = new ArrayList<String>(); input new ArrayList<String>() Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(sc.hasNextLine()){
            String s = sc.nextLine();
            input.add(s);
        } sc.hasNextLine() sc.hasNextLine sc {
            String s = sc.nextLine();
            input.add(s);
        } String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc input.add(s) input.add input s sc.close() sc.close sc String output = ""; output "" String f = input.get(0).substring(0, 2); f input.get(0).substring(0, 2) input.get(0).substring input.get(0) input.get input 0 0 2 String b = input.get(0).substring(2); b input.get(0).substring(2) input.get(0).substring input.get(0) input.get input 0 2 if (ym(f).equals(ym(b)) && ym(f).equals("MM")) {
            output = "AMBIGUOUS";
        } else if (ym(f).equals(ym(b)) && ym(f).equals("YY")) {
            output = "NA";
        } else if (ym(f).equals("MM")) {
            output = "MMYY";
        } else if (ym(f).equals("YY")) {
            output = "YYMM";
        } ym(f).equals(ym(b)) && ym(f).equals("MM") ym(f).equals(ym(b)) ym(f).equals ym(f) ym f ym(b) ym b ym(f).equals("MM") ym(f).equals ym(f) ym f "MM" {
            output = "AMBIGUOUS";
        } output = "AMBIGUOUS" output "AMBIGUOUS" if (ym(f).equals(ym(b)) && ym(f).equals("YY")) {
            output = "NA";
        } else if (ym(f).equals("MM")) {
            output = "MMYY";
        } else if (ym(f).equals("YY")) {
            output = "YYMM";
        } ym(f).equals(ym(b)) && ym(f).equals("YY") ym(f).equals(ym(b)) ym(f).equals ym(f) ym f ym(b) ym b ym(f).equals("YY") ym(f).equals ym(f) ym f "YY" {
            output = "NA";
        } output = "NA" output "NA" if (ym(f).equals("MM")) {
            output = "MMYY";
        } else if (ym(f).equals("YY")) {
            output = "YYMM";
        } ym(f).equals("MM") ym(f).equals ym(f) ym f "MM" {
            output = "MMYY";
        } output = "MMYY" output "MMYY" if (ym(f).equals("YY")) {
            output = "YYMM";
        } ym(f).equals("YY") ym(f).equals ym(f) ym f "YY" {
            output = "YYMM";
        } output = "YYMM" output "YYMM" System.out.println(output) System.out.println System.out System System.out output String[] args args private static String ym(String str) {
        String s;
        int a = Integer.parseInt(str);
        if (a >= 1 && a <= 12) {
            s = "MM";
        } else {
            s = "YY";
        }
        return s;
    } ym {
        String s;
        int a = Integer.parseInt(str);
        if (a >= 1 && a <= 12) {
            s = "MM";
        } else {
            s = "YY";
        }
        return s;
    } String s; s int a = Integer.parseInt(str); a Integer.parseInt(str) Integer.parseInt Integer str if (a >= 1 && a <= 12) {
            s = "MM";
        } else {
            s = "YY";
        } a >= 1 && a <= 12 a >= 1 a 1 a <= 12 a 12 {
            s = "MM";
        } s = "MM" s "MM" {
            s = "YY";
        } s = "YY" s "YY" return s; s String str str public class Main {
    public static void main(String[] args) {
        ArrayList<String> input = new ArrayList<String>();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            input.add(s);
        }
        sc.close();

        String output = "";

        String f = input.get(0).substring(0, 2);
        String b = input.get(0).substring(2);

        if (ym(f).equals(ym(b)) && ym(f).equals("MM")) {
            output = "AMBIGUOUS";
        } else if (ym(f).equals(ym(b)) && ym(f).equals("YY")) {
            output = "NA";
        } else if (ym(f).equals("MM")) {
            output = "MMYY";
        } else if (ym(f).equals("YY")) {
            output = "YYMM";
        }

        System.out.println(output);
    }

    private static String ym(String str) {
        String s;
        int a = Integer.parseInt(str);
        if (a >= 1 && a <= 12) {
            s = "MM";
        } else {
            s = "YY";
        }
        return s;
    }
} public class Main {
    public static void main(String[] args) {
        ArrayList<String> input = new ArrayList<String>();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            input.add(s);
        }
        sc.close();

        String output = "";

        String f = input.get(0).substring(0, 2);
        String b = input.get(0).substring(2);

        if (ym(f).equals(ym(b)) && ym(f).equals("MM")) {
            output = "AMBIGUOUS";
        } else if (ym(f).equals(ym(b)) && ym(f).equals("YY")) {
            output = "NA";
        } else if (ym(f).equals("MM")) {
            output = "MMYY";
        } else if (ym(f).equals("YY")) {
            output = "YYMM";
        }

        System.out.println(output);
    }

    private static String ym(String str) {
        String s;
        int a = Integer.parseInt(str);
        if (a >= 1 && a <= 12) {
            s = "MM";
        } else {
            s = "YY";
        }
        return s;
    }
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        ArrayList<String> input = new ArrayList<String>();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            input.add(s);
        }
        sc.close();

        String output = "";

        String f = input.get(0).substring(0, 2);
        String b = input.get(0).substring(2);

        if (ym(f).equals(ym(b)) && ym(f).equals("MM")) {
            output = "AMBIGUOUS";
        } else if (ym(f).equals(ym(b)) && ym(f).equals("YY")) {
            output = "NA";
        } else if (ym(f).equals("MM")) {
            output = "MMYY";
        } else if (ym(f).equals("YY")) {
            output = "YYMM";
        }

        System.out.println(output);
    }

    private static String ym(String str) {
        String s;
        int a = Integer.parseInt(str);
        if (a >= 1 && a <= 12) {
            s = "MM";
        } else {
            s = "YY";
        }
        return s;
    }
}
