2574. Principles of Compiler

单点时限: 2.0 sec

内存限制: 256 MB

After learnt the Principles of Compiler,partychen thought that he can solve a simple expression problem.So he give you strings of less than 100 characters which strictly adhere to the following grammar (given in EBNF):

A:= ‘(‘ B’)’|’x’.

B:=AC.

C:={‘+’A}.

Can you solve them too?

输入格式

The first line of input gives the number of cases, N(1 ≤ N ≤ 100). N test cases follow.

The next N lines will each contain a string as described above.

输出格式

For each test case,if the expression is adapt to the EBNF above output “Good”,else output “Bad”.

样例

Input
3
(x)
(x+(x+x))
()(x)
Output
Good
Good
Bad

73 人解决,169 人已尝试。

91 份提交通过,共有 867 份提交。

5.5 EMB 奖励。

创建: 15 年,7 月前.

修改: 7 年,2 月前.

最后提交: 4 月,1 周前.

来源: 2009 华东师范大学 研究生复试

题目标签