시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 19 7 7 58.333%

문제

As a C/Java programmer, you will be used to dealing with brackets. For the purpose of this problem, we will consider three type of bracket, round (), square [] and curly {}. As you know, every opening bracket must have a corresponding closing bracket, and brackets must be correctly nested. 

This problem will give you some pieces of code. You have to check whether the brackets are legal or not. To keep things simple, there will be no brackets enclosed in quotes (which do not follow the standard rules, of course). New line characters have also been removed, so each line of input represents one piece of code to be checked.

입력

Input will consist of a number of lines of text (code), each one containing no more than 250 characters. The last line of input will contain just # - this line should be ignored. Each piece of code must be checked for legal brackets, and its status reported.

출력

If a line of code contains no brackets, or if all brackets are correctly paired and nested, the output should be Legal on a line on its own. If there are any errors, the output should be Illegal on a line on its own. 

예제 입력

void test(int num) { num = double(num); }
int count(int value) { return (value + 2; }
while(sum < 200) { sum += data[test(sum]); }
#

예제 출력

Legal
Illegal
Illegal

힌트