#C4430. Valid Parentheses Checker

    ID: 47968 Type: Default 1000ms 256MiB

Valid Parentheses Checker

Valid Parentheses Checker

You are given a string S that consists only of the characters ('), {'}, and [']. Your task is to determine whether the input string is valid.

A string is considered valid if:

  • Every opening bracket has a corresponding closing bracket.
  • The pairs of brackets are properly nested.

You may refer to the following formal definition using LaTeX:

\( S = \epsilon \quad \text{or} \quad S = \big( S \big) \quad \text{or} \quad S = \big\{ S \big\} \quad \text{or} \quad S = \big[ S \big] \quad \text{or} \quad S = S_1 S_2 \)

Implement your solution so that it reads from stdin and writes the result to stdout as either True or False depending on whether the string is valid.

inputFormat

The input consists of a single line containing the string S that you need to check. The string will contain only the characters '(', ')', '{', '}', '[' and ']'.

Note: The input is provided via stdin.

outputFormat

Output a single line to stdout containing True if the string is valid, and False otherwise.

## sample
()
True