eval(input());print((['DENIED','APPROVED'][all([i%3<1 or i%5<1 for i in list(map(int,input().split())) if i%2<1])]))
eval(input());print((['DENIED','APPROVED'][all(i%3<1 or i%5<1 for i in map(int,input().split()) if i%2<1)]))
eval(input())
print(
    (
        ["DENIED", "APPROVED"][
            all(
                [
                    i % 3 < 1 or i % 5 < 1
                    for i in list(map(int, input().split()))
                    if i % 2 < 1
                ]
            )
        ]
    )
)

eval(input())
print(
    (
        ["DENIED", "APPROVED"][
            all(i % 3 < 1 or i % 5 < 1 for i in map(int, input().split()) if i % 2 < 1)
        ]
    )
)

-            all( -                [ -                    i % 3 < 1 or i % 5 < 1 -                    for i in list(map(int, input().split())) -                    if i % 2 < 1 -                ] -            ) +            all(i % 3 < 1 or i % 5 < 1 for i in map(int, input().split()) if i % 2 < 1)