Herok, the fastest typist in the world, has a special keyboard. The keyboard only has different keys each representing a different character. All the keys are on a single line. The first key at the leftmost position, the second one at the second from left position, and so on. As it’s a one-line keyboard, he can type with two fingers only, otherwise, it gets too complicated.
Herok starts with one of his two usable fingers at the leftmost key and the other one at the rightmost key. He types out a sequence of characters one by one, starting from the first character. To type a character, if there is a finger positioned at the corresponding key, Herok immediately presses the key to type the character, otherwise, he moves one of his fingers to the key and then presses the key. On deciding which finger to move, he always chooses the one that’s closest to the key, if both of the fingers are at the same distance, he always chooses the left finger. To move a finger from key at position to key at position , he needs time, here means the absolute value of . He is so fast that he doesn't require any time to press the key.
Herok wonders for some value , what is the minimum possible length of the character sequence for which he will need exactly unit of time to type that sequence. Can you help him?
Input starts with , the number of testcases.
The next lines contain two integers each, , described above.
The sum of in all the test cases doesn’t exceed .
For each test case, in one line print an integer, the minimum possible length of the character sequence for which he will need exactly unit of time to type that sequence. If no such sequence exists print .
3 5 1 2 5 26 19
1 -1 2