Under construction

Still being built. Things may change

Cantor Set

Interview

Time limit1sMemory limit128 MB

Summary
Given a decimal x between 0 and 1 that ends within 6 fractional digits, decide whether x lies in the Cantor set, that is, whether some ternary expansion of x avoids the digit 1.
Level

Medium5 of 10

Topics
Math, Number theory, Implementation, Combinatorics
Solved
No attempts yet

Problem

The ternary expansion of a number is that number written in base 3. A number can have more than one ternary expansion. A ternary expansion is indicated with a subscript 3. For example, 1=13=0.222…31 = 1_3 = 0.222\ldots_3, and 0.875=0.212121…30.875 = 0.212121\ldots_3.

The Cantor set is defined as the real numbers between 0 and 1 inclusive that have a ternary expansion that does not contain a 1. If a number has more than one ternary expansion, it is enough for a single one to not contain a 1.

For example, 0=0.000…30 = 0.000\ldots_3 and 1=0.222…31 = 0.222\ldots_3, so they are in the Cantor set. But 0.875=0.212121…30.875 = 0.212121\ldots_3 and this is its only ternary expansion, so it is not in the Cantor set.

Your task is to determine whether a given number is in the Cantor set.

Input

The input consists of several test cases.

Each test case consists of a single line containing a number xx written in decimal notation, with 0≤x≤10 \le x \le 1, and having at most 6 digits after the decimal point.

The last line of input is END. This is not a test case.

Output

For each test case, output MEMBER if xx is in the Cantor set, and NON-MEMBER if xx is not in the Cantor set.

Examples1

  1. Example 1

    Input
    0
    1
    0.875
    END
    
    Expected output
    MEMBER
    MEMBER
    NON-MEMBER