#K80782. Validate Trading Card Game Trades
Validate Trading Card Game Trades
Validate Trading Card Game Trades
You are given test cases. Each test case describes a series of trades in a trading card game. Initially, there are different types of cards, and you are provided with an array of integers, where the integer represents the number of cards of type . Following that, you will perform trades. Each trade is given by four integers , meaning that you trade cards of type to receive cards of type . A trade is valid only if, at the time of the trade, you have at least cards of type . If any trade is invalid, then the entire test case is marked as "Invalid"; otherwise, it is "Valid".
Your task is to determine for each test case whether the sequence of trades is valid.
inputFormat
The input is given via standard input (stdin) and has the following format:
- The first line contains an integer , representing the number of test cases.
- For each test case:
- The first line contains two integers and , where is the number of card types and is the number of trades.
- The second line contains space-separated integers, representing the initial count of each card type.
- Each of the next lines contains four space-separated integers: , , , , describing a trade as explained above.
All input is read from stdin.
outputFormat
For each test case, output a single line to standard output (stdout) containing either "Valid" or "Invalid" based on whether the sequence of trades is valid.## sample
3
3 3
5 10 5
1 2 4 3
3 1 2 2
2 3 1 1
2 2
3 5
1 2 4 6
2 1 3 5
2 1
5 5
1 2 2 2
Valid
Invalid
Valid
</p>