x = list(input())
first = 10 * int(x[0]) + int(x[1])
second = 10 * int(x[2]) + int(x[3])


def mc(num):
    if 1 <= num <= 12:
        return True
    else:
        return False


def yc(num):
    if 0 <= num <= 99:
        return True
    else:
        return False


if yc(first):
    if mc(second):
        if yc(second):
            if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
        else:
            print("YYMM")
    elif yc(second):
        if mc(first):
            print("MMYY")
        else:
            print("NA")
    else:
        print("NA")
elif yc(second):
    if mc(first):
        print("MMYY")
    else:
        print("NA")
else:
    print("NA") x = list(input()) x list(input()) list input() input first = 10 * int(x[0]) + int(x[1]) first 10 * int(x[0]) + int(x[1]) 10 * int(x[0]) 10 int(x[0]) int x[0] x 0 int(x[1]) int x[1] x 1 second = 10 * int(x[2]) + int(x[3]) second 10 * int(x[2]) + int(x[3]) 10 * int(x[2]) 10 int(x[2]) int x[2] x 2 int(x[3]) int x[3] x 3 def mc(num):
    if 1 <= num <= 12:
        return True
    else:
        return False mc if 1 <= num <= 12:
        return True
    else:
        return False 1 <= num <= 12 1 <= num 1 num 12 return True True return False False num num def yc(num):
    if 0 <= num <= 99:
        return True
    else:
        return False yc if 0 <= num <= 99:
        return True
    else:
        return False 0 <= num <= 99 0 <= num 0 num 99 return True True return False False num num if yc(first):
    if mc(second):
        if yc(second):
            if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
        else:
            print("YYMM")
    elif yc(second):
        if mc(first):
            print("MMYY")
        else:
            print("NA")
    else:
        print("NA")
elif yc(second):
    if mc(first):
        print("MMYY")
    else:
        print("NA")
else:
    print("NA") yc(first) yc first if mc(second):
        if yc(second):
            if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
        else:
            print("YYMM")
    elif yc(second):
        if mc(first):
            print("MMYY")
        else:
            print("NA")
    else:
        print("NA") mc(second) mc second if yc(second):
            if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
        else:
            print("YYMM")
     yc(second) yc second if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
         mc(first) mc first print("AMBIGUOUS") print "AMBIGUOUS" print("YYMM") print "YYMM" print("YYMM") print "YYMM" elif yc(second):
        if mc(first):
            print("MMYY")
        else:
            print("NA")
     yc(second) yc second if mc(first):
            print("MMYY")
        else:
            print("NA")
     mc(first) mc first print("MMYY") print "MMYY" print("NA") print "NA" print("NA") print "NA" elif yc(second):
    if mc(first):
        print("MMYY")
    else:
        print("NA") yc(second) yc second if mc(first):
        print("MMYY")
    else:
        print("NA") mc(first) mc first print("MMYY") print "MMYY" print("NA") print "NA" print("NA") print "NA" def mc(num):
    if 1 <= num <= 12:
        return True
    else:
        return False def mc(num):
    if 1 <= num <= 12:
        return True
    else:
        return False mc def yc(num):
    if 0 <= num <= 99:
        return True
    else:
        return False def yc(num):
    if 0 <= num <= 99:
        return True
    else:
        return False yc first = 10 * int(x[0]) + int(x[1]) 10 * int(x[0]) + int(x[1]) first x = list(input()) list(input()) x second = 10 * int(x[2]) + int(x[3]) 10 * int(x[2]) + int(x[3]) second
x = list(input())
first = 10 * int(x[0]) + int(x[1])
second = 10 * int(x[2]) + int(x[3])


def mc(num):
    if 1 <= num <= 12:
        return True
    else:
        return False


def yc(num):
    if 0 <= num <= 99:
        return True
    else:
        return False


if yc(first):
    if mc(second):
        if yc(second):
            if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
        else:
            print("YYMM")
    elif yc(second):
        if mc(first):
            print("MMYY")
        else:
            print("NA")
    else:
        print("NA")
elif yc(second):
    if mc(first):
        print("MMYY")
    else:
        print("NA")
else:
    print("NA")
