Chef is all ready to show his new dish at the restaurant but he is very scared if the people dislike it. He wants to show them his dish at a perfect time, so that all may like the dish.
If the time displayed as HH:MM, where HH is the hour and MM is the minute then, for the Chef's time to be lucky it should be of the format  XY:YX, XY:XY or XX:YY, in which X and Y show occurrence of same number. Here X and Y can be same.
An assistant of Chef gives him a string of possible perfect times separated by space, you have to help Chef to determine what is the number of perfect times in the given string.

 

Input
First line of input will consist of number of test cases t.
The subsequent t lines will consist of a string of possible perfect times in the format HH:MM where HH is hours and MM is minutes, separated by a space
 

Output
For every input, output will be a single line, containing the number of Perfect Times in the string
 

Constraints

1 ≤ t ≤ 500
00 ≤ HH ≤ 23
00 ≤ MM ≤ 59
There can be 1 to 50 (both inclusive) possible perfect times given in a string

 

Example
Input:
2
12:21 11:10
06:00

Output:
1
0
for _ in range(input()):
	s=raw_input().split()
	c=0
	for i in range(len(s)):
		if s[i][0]==s[i][4] and s[i][1]==s[i][3]:
			c+=1
		elif s[i][0]==s[i][1]and s[i][3]==s[i][4]:
			c+=1
		elif s[i][0]==s[i][3] and s[i][1]==s[i][4]:
			c+=1
	print c