401934: GYM100589 B Count Palindromes

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Count Palindromestime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

Given two times when seen on a digital clock, count the number of moments between these two times (both start and end time included) when the time was a palindrome.

A digital clock shows time in the format HH:MM:SS (hours:minutes:seconds).

For example, 2:40:38 pm is represented as 14:40:38.

Input

The first line contains q ( ≤ 105) queries. This is followed by q lines each containing two time strings, t1 and t2, which are 6 digit integers that represent times shown by a digital clock. It is ensured that t1 and t2 are valid times(t1 occurs on or before t2).

Output

For each query in one line print the number of palindromic times.

ExamplesInput
4
00:00:01 00:00:01
09:09:09 13:34:57
11:11:11 11:11:11
02:38:15 03:01:16
Output
0
22
1
3
Note

Query 1: Only 1 moment is considered in this case, i.e., 00:00:01. We can clearly see that 00:00:01 is not a palindromic string.

Query 4: Between 02:38:15 and 03:01:16, there are 3 moments that are palindromic strings. They are 02:44:20, 02:55:20 and 03:00:30.

Note that the time as seen on a digital clock should appear as a palindrome. 1 is a palindrome, but 00:00:01 on a digital clock is not.

加入题单

上一题 下一题 算法标签: