The world must be well balanced — like positive and negative, light and dark, and left and right brackets.
Jeongmin's task is to write a program that, given a string, decides whether the brackets inside it are balanced.
A string may contain two kinds of brackets: round brackets ( ) and square brackets [ ]. A string is balanced when all of the following hold:
( pairs only with a right round bracket ).[ pairs only with a right square bracket ].Help Jeongmin decide whether each given string is balanced.
The input consists of several lines. Except for its last character, each line (string) consists of English letters, spaces, round brackets ( ), and square brackets [ ], always ends with a period ., and is at most 100 characters long.
The input ends with a line containing a single period .; this terminating line is not processed.
For each string, print yes on its own line if it is balanced, or no otherwise.
A string that contains no brackets at all (for example, a string of only spaces) is also considered balanced.