#C8156. Vault Unlocking

    ID: 52107 Type: Default 1000ms 256MiB

Vault Unlocking

Vault Unlocking

You are given a list of binary states. The vault has an initial state of 000 and a target state of 111. You can move from one state to another if and only if the two binary strings differ by exactly one bit. In other words, for two states \( a = a_1a_2a_3 \) and \( b = b_1b_2b_3 \), a move is allowed if and only if

[ \sum_{i=1}^{3} \mathbf{1}_{{a_i \neq b_i}} = 1 ]

Your task is to determine whether there exists a sequence of valid moves starting from 000 and ending at 111, such that every intermediate state is in the given list. If such a sequence exists, output OPEN; otherwise, output LOCKED.

inputFormat

The first line of input contains an integer ( n ) representing the number of binary states. The following ( n ) lines each contain a binary string of length 3, representing an allowed state.

outputFormat

Output a single line containing either "OPEN" if it is possible to transform the state 000 into 111 via a series of valid moves (where each move changes exactly one bit), or "LOCKED" otherwise.## sample

8
000
001
010
011
100
101
110
111
OPEN