PivotOJ

Reverse Engineering

시간 제한: 2000ms메모리 제한: 1024MB출처: USACO 2022 December BronzeBOJ 26977

문제

Elsie has a program that takes as input an array of NN (1N1001\le N\le 100) variables b[0],,b[N1]b[0],\dots,b[N-1], each equal to zero or one, and returns the result of applying a sequence of if / else if / else statements on the input. Each statement examines the value of at most one input variable, and returns either zero or one. An example of such a program might be:

if (b[1] == 1) return 1;
else if (b[0] == 0) return 0;
else return 1;

For example, if the input to the program above is "10" (that is, b[0]=1b[0] = 1 and b[1]=0b[1] = 0), then the output should be 1.

Elsie has told Bessie the correct output for MM (1M1001\le M\le 100) different inputs. Bessie is now trying to reverse engineer Elsie's program. Unfortunately, Elsie might have lied; it may be the case that no program of the form above is consistent with what Elsie said.

For each of TT (1T101\le T\le 10) test cases, determine whether Elsie must be lying or not.

입력

The first line contains TT, the number of test cases.

Each test case starts with two integers NN and MM, followed by MM lines, each containing a string of NN zeros and ones representing an input (that is, the values of b[0]b[N1]b[0] \ldots b[N-1]) and an additional character (zero or one) representing the output. Consecutive test cases are separated by newlines.

출력

For each test case, output "OK" or "LIE" on a separate line.

힌트

Here's a valid program for the first test case:

if (b[0] == 0) return 0;
else return 1;

Another valid program for the first test case:

if (b[0] == 1) return 1;
else return 0;

A valid program for the second test case:

if (b[1] == 1) return 1;
else if (b[0] == 0) return 0;
else return 1;

Clearly, there is no valid program corresponding to the third test case, because Elsie's program must always produce the same output for the same input.

It may be shown that there is no valid program corresponding to the last test case.

예제

예제 1

입력
4

1 3
0 0
0 0
1 1

2 4
00 0
01 1
10 1
11 1

1 2
0 1
0 0

2 4
00 0
01 1
10 1
11 0
출력
OK
OK
LIE
LIE
코드를 제출하려면 로그인하세요.