</>CodexBash
Back to problems
Not started

Valid parentheses

Easy
2000 ms limit256 MB memoryStringsStacks and queues

Stuck?

Show a hint

The correct partner for a closing bracket is always the most recent unmatched opening one, which is what a stack gives you.

Given a string containing only the characters ()[]{}, decide whether the brackets are balanced.

Brackets must close in the correct order, and every opening bracket must have a matching closing bracket of the same type.

Constraints#

  • 1 <= length <= 100000

Input

s is one line holding the string.

Output

`true` if the brackets are balanced, otherwise `false`.

Examples

Input

()[]{}

Output

true

Every bracket closes in the right order.

Input

(]

Output

false

Something wrong with this problem? Report an issue

Ready to try it

Write your solution in C, C++, Java or Python and see every test case come back with the time and memory it took.

Free, and it stays free. No card.