UF2015G - Combination Lock

no tags 

After hanging out in the fish bowl (also called the ACM room if you're a scrub) for what seemed like an eternity Joon wanted to go grab an ice cold beverage from the refrigerator. Recently, however, a two-digit combination lock was added to the refrigerator door to prevent unauthorized access (Joon); fortunately Joon already knows the two-digit combination that will unlock the refrigerator door!

Joon is good with numbers but is incredibly lazy, therefore he wants to unlock the door with as little effort as possible. To unlock the door he will make a sequence of moves where each move can alter one of the digits on the lock by either incrementing it or decrementing it (increase/decrease by 1). If Joon increments a digit set to 9, then the digit wheel will wrap around to 0. Similarly, if Joon decrements a digit set to 0 it will wrap around to 9.

Given the initial configuration of the combination lock and the unlocked configuration, can you determine the minimum number of moves Joon must make to open the refrigerator door?

Input

The input will begin with a line containing a single positive integer, t, representing the number of test cases to process. Each test case consists of a single line with four integers x1, y1, x2, y2 (0 ≤ x1, y1, x2, y2 9) where (x1, y1) is the initial configuration of the lock and (x2, y2) is the unlocked configuration.

Output

For each test case print the minimum number of moves Joon must make to open the refrigerator door, each on its own line.

Example

Input:
2
0 9 1 3
4 5 7 2 Output: 5
6


Added by:Cormac
Date:2015-02-19
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 JS-MONKEY
Resource:UF High School Programming Contest 2015