It's already late and ThunderCracker needs to get up early tomorrow. He needs to quickly set his alarm so that he wakes up on time. This is how his alarm looks :
The alarm follows the $$12$$-hr format (i.e. hh $$\in [1, 12]$$, mm $$\in [0, 59]$$). To adjust the time of the alarm, there are $$5$$ keys that can be pressed : (hh+), (hh-), (mm+), (mm-), (#).
|hh+||Increases the hour by 1. If hh is 12, it becomes 1.|
|hh-||Decreases the hour by 1. If hh is 1, it becomes 12.|
|mm+||Increases the minute by 1. If mm is 59, it becomes 0, and the hour increases by 1.|
|mm-||Decreases the minute by 1. If mm is 0, it becomes 59, and the hour decreases by 1.|
|#||Toggles betweem am and pm.|
|Additionally, whenever hh changes from 11 to 12, or 12 to 11, the am/pm is toggled internally.|
Here are some examples to understand how the alarm works :
|Current Time||Move||Time to be Set|
|11:44 pm||mm+||11:45 pm|
|11:45 pm||hh+||12:45 am|
|12:45 am||hh+||01:45 am|
|01:45 am||#||01:45 pm|
|12:00 pm||hh-||11:00 am|
|11:59 am||mm+||12:00 pm|
You are given the time that the alarm shows currently, and also the time for which the alarm is to be set. Help ThunderCracker set the alarm in the minimum number of moves (where each move represents a press of any of the keys.)
The first line of the input consists of $$T$$, the number of test cases. $$T$$ test cases follow.
Each test case consists of $$2$$ lines, the current time on the alarm, and the time to be set respectively, both in hh:mm am/pm format. (See sample input for details)
For each test case, print on a new line, a single integer, denoting the minimum number of moves required to set the alarm.
$$1 ≤ T ≤ 10^4$$
All the times will be in valid $$12$$-hr format.
Note : This problem has binary scoring. You will receive points only if you pass all test files successfully.
For the first test case, the moves required are : (mm+), (mm+), (mm+), (mm+), (mm+), (#).
For the second test case, the moves required are : (#), (hh+).