def solve():
    s = input()
    a = int(s[:2])
    if a == 0 or a > 12:
        x = "YY"
    else:
        x = "MM"
    b = int(s[2:])
    if b == 0 or b > 12:
        y = "YY"
    else:
        y = "MM"
    if x + y == "YYYY":
        print("NA")
    elif x + y == "MMMM":
        print("AMBIGUOUS")
    else:
        print(x + y)


solve() def solve():
    s = input()
    a = int(s[:2])
    if a == 0 or a > 12:
        x = "YY"
    else:
        x = "MM"
    b = int(s[2:])
    if b == 0 or b > 12:
        y = "YY"
    else:
        y = "MM"
    if x + y == "YYYY":
        print("NA")
    elif x + y == "MMMM":
        print("AMBIGUOUS")
    else:
        print(x + y) solve s = input() s input() input a = int(s[:2]) a int(s[:2]) int s[:2] s :2 2 if a == 0 or a > 12:
        x = "YY"
    else:
        x = "MM"
     a == 0 or a > 12 a == 0 a 0 a > 12 a 12 x = "YY" x "YY" x = "MM" x "MM" b = int(s[2:]) b int(s[2:]) int s[2:] s 2: 2 if b == 0 or b > 12:
        y = "YY"
    else:
        y = "MM"
     b == 0 or b > 12 b == 0 b 0 b > 12 b 12 y = "YY" y "YY" y = "MM" y "MM" if x + y == "YYYY":
        print("NA")
    elif x + y == "MMMM":
        print("AMBIGUOUS")
    else:
        print(x + y) x + y == "YYYY" x + y x y "YYYY" print("NA") print "NA" elif x + y == "MMMM":
        print("AMBIGUOUS")
     x + y == "MMMM" x + y x y "MMMM" print("AMBIGUOUS") print "AMBIGUOUS" print(x + y) print x + y x y solve() solve def solve():
    s = input()
    a = int(s[:2])
    if a == 0 or a > 12:
        x = "YY"
    else:
        x = "MM"
    b = int(s[2:])
    if b == 0 or b > 12:
        y = "YY"
    else:
        y = "MM"
    if x + y == "YYYY":
        print("NA")
    elif x + y == "MMMM":
        print("AMBIGUOUS")
    else:
        print(x + y) def solve():
    s = input()
    a = int(s[:2])
    if a == 0 or a > 12:
        x = "YY"
    else:
        x = "MM"
    b = int(s[2:])
    if b == 0 or b > 12:
        y = "YY"
    else:
        y = "MM"
    if x + y == "YYYY":
        print("NA")
    elif x + y == "MMMM":
        print("AMBIGUOUS")
    else:
        print(x + y) solve
def solve():
    s = input()
    a = int(s[:2])
    if a == 0 or a > 12:
        x = "YY"
    else:
        x = "MM"
    b = int(s[2:])
    if b == 0 or b > 12:
        y = "YY"
    else:
        y = "MM"
    if x + y == "YYYY":
        print("NA")
    elif x + y == "MMMM":
        print("AMBIGUOUS")
    else:
        print(x + y)


solve()
