BasicAlgorithms10 points

Does this template close properly?

A code editor used by a software team in Bengaluru highlights an error when brackets in a file are not closed properly. A bracket string is balanced when every opening bracket is closed by the matching type of bracket, in the correct order (so ([]) is balanced but ([)] and (() are not).

Task: the input is a single line of 1 to 400 characters, each one of ( ) [ ] { }. Print YES if the string is balanced, otherwise print NO.

Sample test

Input

{[()]}()

Expected output

YES

Your answer is also checked against 6 hidden tests.

Need a hint?

Think of a stack of plates: the most recent opening bracket must be the first one to be closed.