All submissions for this problem are available.You have a stack which is initially empty. You receive instructions of the form 1 or 0. 1 denotes that you have to push in an element, and 0 denotes that you have to pop out an element. But of course you can pop something out only if it exists in the stack. So your job is to look at the instructions and see if they are valid (ie. you never have to pop from an empty stack), or not.
The first line of the input contains a single integers T, which denotes the number of testcases.
The first line of each testcase contains a single integer n, which denotes the number of instructions.
The second line contains n space separated integers, which are all 0 or 1.
For each testcase output either “Valid” or “Invalid”, in a new line.
All instructions are either 0 or 1.
1 1 0 0 1
1 0 0 1 1