HoshiYo is learning Black Magic with n blocks. The left and right sides of each block are painted black or white. HoshiYo arranges the blocks in a row in a certain order without rotating them and then releases the Black Magic. Here's what happens next:For any two adjacent blocks, if the right side of the left block and the left side of the right block are both painted black, then the two sides will be pasted together making the two blocks into one.
HoshiYo wants to know the minimum and maximum blocks he can get after releasing the Black Magic.
The first line contains an integer T 1≤T≤4×103), indicating the number of test cases.
Each test case contains four integers E,L,R,B 0≤E,L,R,B≤105,E+L+R+B≥1), indicating the number of blocks.
3
1 1 1 1
1 2 3 4
3 4 5 6
2 4
4 8
8 16
Let's denote a block by (x,y), where xx indicates the color on the left side, and y indicates the color on the right side. We use 00 to represent white and 11 to represent black.
For the first test case in the sample, here is a possible solution to get the minimum number of blocks:
(0,0)(0,1)(1,1)(1,0)
As shown above, the last three blocks will be pasted into one.
And here is a possible solution to get the maximum number of blocks:
(0,0)(1,0)(1,1)(0,1)
As shown above, any two blocks will not be pasted together.