6. Balanced Brackets - C#

You will receive n lines. On those lines, you will receive one of the following:

· Opening bracket – '(',

· Closing bracket – ')' or

· Random string

Your task is to find out if the brackets are balanced. That means after every opening bracket should follow an closing one. Nested parentheses are not valid and if two consecutive opening brackets exist, the expression should be marked as unbalanced.

Input

· On the first line, you will receive n – the number of lines, which will follow.

· On the next n lines, you will receive '(', ')' or another string.

Output

You have to print "BALANCED", if the parentheses are balanced and "UNBALANCED" otherwise.

Constraints

· n will be in the interval [1…20].

· The length of the stings will be between [1…100] characters.

Моят код: https://pastebin.com/U2rjuWzG
Дава ми 85 точки от 100.  Четвъртия тест е грешен

Знам, че има и други хора, които са решавали задачата във форума, но не успях да открия някой, който да я е решил по начин, подобен на моя.


EDIT
Всичко ми е вярно без последната част. Най - лесното съм го объркал XD . Ето така трябва да изглежда кода: 
https://pastebin.com/HMpAPb4D