P21932 [HackerEarth] After India vs South Africa Match , Ananth and Arpit got bored and started playing a Game.
普及
题目描述

After India vs South Africa Match , Ananth and Arpit got bored and started playing a Game.

The Game goes as follows.
The Game consists of two players and are given 2 numbers P and Q in the beginning .
In each turn one of the player can select any of the two numbers and subtract K times the other number from the selected number where k>0 and replaces the selected number with the result.
If a player cannot play the step -2 without making any one of the 2 numbers ≤ zero then he will lose.

If the initial numbers are 5 and 3
Ananth will start the game . He will select 5 and replaces it with
5-3k where k = 1 [ He cannot substitute the number with k = 2
because 5-6 < 0 and he cannot select 3 because 3-5k ≤0 for all K >
0 ]
Now the numbers are 2 and 3 Arpit selects 3 and replaces it with
3-2k where k = 1.
Now the numbers are 2 1 and Ananth selects 2 and replaces it with
2-1
k where k = 1.
Now the numbers are 1 1 and Arpit Lose the game as he cannot make a
move without making any one of the numbers ≤ zero

Here [5,3] is a winning position for Ananth. Given that Ananth always starts the game and [P1,P2] and [Q1,Q2], find the Number of winning positions of Ananth [P,Q] such that P1 ≤ P ≤ P2 and Q1 ≤ Q ≤ Q2

Input

First Line of the Input file contains T. Next T lines contains 4 numbers in each line P1 P2 Q1 and Q2

Output:

Print the result for each test case in a new line

Constraints :

1 ≤ T ≤ 100.

1 ≤ P1 ≤ P2 ≤ 1000000.

1 ≤ Q1 ≤ Q2 ≤ 1000000.

SAMPLE INPUT
2
5 5 3 3
5 5 8 8

SAMPLE OUTPUT
1
0

输入格式

见题面

输出格式

见题面

样例输入
100 5 5 8 8 11 11 2 2 1 6 1 6 1 5 9 20 1 1 1 1 1000000 1000000 1000000 1000000 1000000 1000000 1 1 1 31 1 31 39 39 24 24 31 56 1 22 1 9 43 71 3 23 34 62 10 36 37 62 13 43 33 60 40 62 1 30 8 26 43 49 19 33 48 64 14 32 40 66 41 71 20 36 27 57 4 31 18 30 32 49 36 57 23 30 30 54 21 44 1 30 20 50 5 25 15 29 7 24 20 48 2 31 14 42 10 37 27 46 1 29 19 44 17 42 15 39 24 39 13 40 254 254 411 411 157 177 483 509 476 505 194 213 479 506 382 400 478 507 232 260 264 272 481 503 323 343 496 507 291 317 479 509 490 520 302 328 299 327 493 517 275 303 467 495 292 314 463 492 279 308 472 495 273 300 474 500 411 439 242 272 241 269 407 434 304 330 380 404 172 201 337 367 449 479 482 492 298 324 449 471 362 392 33 45 494 497 296 324 20 44 111 136 43784 43784 27060 27060 5245 5255 49996 50023 39996 40007 48657 48675 25240 25252 49054 49083 49535 49563 29875 29904 30863 30887 49784 49814 49961 49982 30900 30922 30840 30870 49946 49974 49880 49909 30815 30844 49890 49910 30824 30848 49892 49921 30835 30854 30619 30649 49533 49560 48841 48868 30197 30226 29116 29146 47107 47134 44390 44408 27426 27456 43761 43785 27051 27066 39688 39713 24023 24048 44976 44987 11154 11183 48855 48884 32014 32032 15668 15692 3966 3975 4728 4758 26422 26445 38717 38741 35494 35518 12857 12878 49084 49110 560597 560597 907065 907065 410704 410712 999988 1000000 632250 632279 499996 500026 623065 623090 996158 996183 607774 607803 975913 975940 606661 606680 980413 980425 997458 997479 616500 616527 996804 996834 616050 616080 998698 998716 617216 617245 617582 617608 999293 999323 998516 998546 617123 617150 995329 995359 615143 615153 991901 991917 613015 613032 992036 992064 613114 613131 900293 900320 556404 556433 439200 439226 710637 710655 882920 882935 241316 241325 481108 481124 635953 635980 202370 202397 402502 402531 501621 501642 645277 645306 552885 552900 224260 224289 399069 399095 99739 99752 931044 931068 430631 430661
样例输出
0 1 20 60 0 0 1 582 1 562 261 603 544 455 660 133 241 460 420 683 136 117 141 655 137 397 487 261 493 163 114 1 567 600 0 870 207 0 459 329 340 654 134 487 706 614 543 0 930 0 0 403 43 650 1 308 0 390 870 0 0 894 659 344 282 108 28 187 278 88 676 360 0 250 744 0 594 1 117 0 0 0 0 0 574 368 725 141 306 292 210 463 77 160 0 840 0 480 378 775