Veshy is entering strings into his calculator consisting of only (
, )
, and decimal digits; however, some strings are invalid and produce an error.
A valid string must either be:
- Nothing (an empty string).
- A non-negative integer expressed in decimal digits (e.g.
5
,230
,0032
), optionally followed by another valid string. - A pair of brackets enclosing a valid string (e.g.
(5)
), also optionally followed by another valid string.
Examples of valid strings:
(1)(2)
, ((1))(2)
, 1(2)
, (500())
Examples of invalid strings:
(12
, (1))
, ((1)()
You are given YES
. If the string is invalid, output NO
. The length in characters of each string,
Constraints
In all tests,
Input Specification
The first line contains one number,
The following
Output Specification
Output the validity of the
Sample Input
Copy
7
1(2)
(1)(2)
((1))(2)
(500())
(12
(1))
((1)()
Sample Output
Copy
YES
YES
YES
YES
NO
NO
NO
Comments
Is ")(" a valid string?
No.