You visit a doctor on a date given in the format $yyyy:mm:dd$. Your doctor suggests you to take pills every alternate day starting from that day. You being a forgetful person are pretty sure won’t be able to remember the last day you took the medicine and would end up in taking  the medicines on wrong days. 
So you come up with the idea of taking medicine on the dates whose day is odd or even depending on whether $dd$ is odd or even. Calculate the number of pills you took on right time before messing up for the first time.

-----Note:-----
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 is not a leap year; the year 2000 is a leap year.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase contains of a single line of input, in the format $yyyy:mm:dd$

-----Output:-----
For each testcase, output in a single line the required answer.

-----Constraints-----
- $ 1 \leq T \leq 1000 $
- $ 1900 \leq yyyy \leq 2038 $
- $yyyy:mm:dd$ is a valid date

-----Sample Input:-----
1
2019:03:31

-----Sample Output:-----
1

-----EXPLANATION:-----
You can take pill on the right day only on 31st March. Next you will take it on 1st April which is not on the alternate day.

Source: codechef | Difficulty: MEDIUM
Tags: Mathematics


Solutions:
t = int(input())
for i in range(t):
	(y, m, d) = map(int, input().split(':'))
	l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	m -= 1
	if y % 400 == 0 or (y % 4 == 0 and y % 100 != 0):
		l[1] = 29
	if m == 0 or m == 2 or m == 4 or (m == 6) or (m == 7) or (m == 9) or (m == 11) or (m == 1 and l[1] == 29):
		print((l[m] - d) // 2 + 1)
	else:
		print((l[m] - d + l[m + 1]) // 2 + 1)


for _ in range(int(input())):
	(yy, mm, dd) = map(int, input().split(':'))
	if mm in [1, 3, 5, 7, 8, 10, 12]:
		ans = (31 - dd) // 2 + 1
	elif mm in [4, 6, 9, 11]:
		ans = (61 - dd) // 2 + 1
	elif yy % 4 == 0 and yy % 100 != 0 or yy % 400 == 0:
		ans = (29 - dd) // 2 + 1
	else:
		ans = (28 + 31 - dd) // 2 + 1
	print(ans)


import datetime as dt
for _ in range(int(input())):
	(y, m, d) = map(int, input().split(':'))
	modulo = d & 1
	cnt = 1
	t = dt.datetime(y, m, d)
	while True:
		t += dt.timedelta(days=2)
		if t.day & 1 != modulo:
			break
		else:
			cnt += 1
	print(cnt)


import datetime
for i in range(int(input())):
	(a, b, c) = map(int, input().split(':'))
	b = datetime.datetime(a, b, c)
	count = 1
	x = c % 2
	while True:
		b = b + datetime.timedelta(days=2)
		if b.day % 2 != x:
			break
		count += 1
	print(count)


import datetime
for i in range(int(input())):
	(y, m, d) = map(int, input().split(':'))
	m = datetime.datetime(y, m, d)
	count = 1
	p = d % 2
	while True:
		m = m + datetime.timedelta(days=2)
		if m.day % 2 != p:
			break
		count += 1
	print(count)


for i in range(int(input())):
	(y, m, d) = list(map(int, input().split(':')))
	if m in [1, 3, 5, 7, 8, 10, 12]:
		sol = (31 - d) // 2 + 1
	elif m in [4, 6, 9, 11]:
		sol = (61 - d) // 2 + 1
	elif y % 4 == 0 and y % 100 != 0 or y % 400 == 0:
		sol = (29 - d) // 2 + 1
	else:
		sol = (59 - d) // 2 + 1
	print(sol)


t = int(input())
for jfdihs in range(t):
	(y, m, d) = map(int, input().split(':'))
	leap = 0
	if y % 4 == 0:
		if y % 100 == 0:
			if y % 400 == 0:
				leap = 1
		else:
			leap = 1
	dates = {1: 31, 2: 28 + leap, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
	if dates[m] % 2 == 0:
		ans = (dates[m] - d + 1 + (1 - d % 2)) // 2 + (31 + d % 2) // 2
	else:
		ans = (dates[m] - d + 1 + d % 2) // 2
	print(ans)


import sys
input = sys.stdin.readline

def rii():
	return range(int(input().strip()))

def ii():
	return int(input().strip())

def mii():
	return map(int, input().strip().split(' '))

def lmii():
	return list(map(int, input().strip().split(' ')))

def si():
	return str(input().strip())
dom = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}

def is_leap_year(y):
	return True if y % 400 == 0 else False if y % 100 == 0 else True if y % 4 == 0 else False

def days_in_month(y, m):
	return dom[m] + (1 if all([is_leap_year(y), m == 2]) else 0)

def solve(s):
	(y, m, d) = map(int, s.split(':'))
	days_in_this_month = days_in_month(y, m)
	ans = days_in_this_month - d + 1 + (1 if d & 1 else 0)
	if days_in_this_month % 2 == 0:
		ans += days_in_month(y, m + 1)
	return ans // 2

def do_codechef():
	for t in rii():
		s = si()
		print(solve(s))
do_codechef()
exit()


for _ in range(int(input())):
	(y, m, d) = map(int, input().split(':'))
	res = 0
	if y % 4 == 0 and y % 100 != 0 or y % 400 == 0:
		months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	else:
		months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	c = 0
	if d % 2 == 0:
		while d % 2 == 0:
			c += 1
			d += 2
			if d > months[m - 1]:
				d = d % months[m - 1]
				m += 1
	else:
		while d % 2 != 0:
			c += 1
			d += 2
			if d > months[m - 1]:
				d = d % months[m - 1]
				m += 1
	print(c)


for _ in range(int(input())):
	s = input().split(':')
	y = int(s[0])
	m = int(s[1])
	d = int(s[2])
	if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
		count = (31 - d) // 2 + 1
	elif m == 4 or m == 6 or m == 9 or (m == 11):
		count = (30 + 31 - d) // 2 + 1
	elif y % 4 == 0 and y % 100 != 0 or y % 400 == 0:
		count = (29 - d) // 2 + 1
	else:
		count = (28 + 31 - d) // 2 + 1
	print(count)


from math import sqrt, ceil, floor, gcd, log2
import sys
from sys import stdin, stdout
from collections import Counter, defaultdict, OrderedDict, deque
from itertools import combinations, groupby
from time import time
from heapq import heappop, heappush, heapify
t = int(input())
for _ in range(t):
	(y, m, d) = map(int, input().split(':'))
	if m in [1, 3, 5, 7, 8, 10, 12]:
		print((31 - d) // 2 + 1)
	elif m in [4, 6, 9, 11]:
		print((61 - d) // 2 + 1)
	elif y % 400 == 0 or (y % 4 == 0 and y % 100 != 0):
		print((29 - d) // 2 + 1)
	else:
		print((59 - d) // 2 + 1)


def snek(x):
	if x % 400 == 0:
		return 1
	elif x % 100 == 0:
		return 0
	elif x % 4 == 0:
		return 1
	else:
		return 0
t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split(':'))
	c = y - 1
	s = 1
	l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	if snek(x):
		l[1] = 29
	if (y == 1 or y == 3 or y == 5 or (y == 7) or (y == 8) or (y == 10) or (y == 12)) or (y == 2 and l[1] == 29):
		s += (l[c] - z) // 2
	else:
		s += (l[c] + l[y] - z) // 2
	print(s)


from math import *
for _ in range(int(input())):
	l = list(map(int, input().split(':')))
	y = l[0]
	m = l[1]
	d = l[2]
	if y % 4 == 0 and y not in [1900, 2100, 2200, 2300]:
		l = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	else:
		l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	ans = 0
	for i in range(d, l[m - 1] + 1, 2):
		ans += 1
	if l[m - 1] % 2 == 0:
		for i in range(2 - d % 2, l[m] + 1, 2):
			ans += 1
	print(ans)


for _ in range(int(input())):
	(y, m, d) = map(int, input().split(':'))
	leapyr = False
	m31 = [1, 3, 5, 7, 8, 10, 12]
	pills = 0
	modd = True
	dodd = True
	if m % 2 == 0:
		modd = False
	if d % 2 == 0:
		dodd = False
	if y % 4 == 0 and y != 1900:
		leapyr = True
	if m in m31:
		pills = (31 - d) // 2 + 1
	elif m == 2 and leapyr == True:
		pills = (29 - d) // 2 + 1
	elif m == 2 and leapyr != True:
		pills = (28 - d) // 2 + 1
		if dodd:
			pills += 16
		else:
			pills += 15
	else:
		pills = (30 - d) // 2 + 1
		if dodd:
			pills += 16
		else:
			pills += 15
	print(pills)


for _ in range(int(input())):
	(y, m, d) = list(map(int, input().split(':')))
	if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
		if d % 2 == 0:
			print((30 - d) // 2 + 1)
		else:
			print((31 - d) // 2 + 1)
	elif m == 4 or m == 6 or m == 9 or (m == 11):
		if d % 2 == 0:
			print((30 - d) // 2 + 16)
		else:
			print((31 - d) // 2 + 16)
	elif y % 4 == 0 and y % 100 != 0 or y % 400 == 0:
		print((29 - d) // 2 + 1)
	elif d % 2 == 0:
		print((28 - d) // 2 + 16)
	else:
		print((27 - d) // 2 + 17)


from math import *
import sys

def input():
	return sys.stdin.readline().replace('\n', '').strip()
sys.setrecursionlimit(10 ** 9)
for _ in range(int(input())):
	l = list(map(int, input().split(':')))
	y = l[0]
	m = l[1]
	d = l[2]
	if y % 4 == 0 and y not in [1900, 2100, 2200, 2300]:
		l = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	else:
		l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	ans = 0
	for i in range(d, l[m - 1] + 1, 2):
		ans += 1
	if l[m - 1] % 2 == 0:
		for i in range(2 - d % 2, l[m] + 1, 2):
			ans += 1
	print(ans)


for _ in range(int(input())):
	list1 = list(map(int, input().split(':')))
	leap = 0
	if list1[0] % 4 == 0:
		if list1[0] % 100 == 0:
			if list1[0] % 400 == 0:
				leap = 1
		else:
			leap = 1
	count = 0
	if list1[1] == 2:
		if leap == 0:
			count += (31 + 28 - list1[2]) // 2 + 1
		else:
			count += (29 - list1[2]) // 2 + 1
	elif list1[1] <= 7:
		if list1[1] % 2 == 0:
			count += (31 + 30 - list1[2]) // 2 + 1
		else:
			count += (31 - list1[2]) // 2 + 1
	elif list1[1] % 2 == 0:
		count += (31 - list1[2]) // 2 + 1
	else:
		count += (31 + 30 - list1[2]) // 2 + 1
	print(count)


from sys import stdin, stdout
ans = []

def leap_check(yy):
	if yy % 400 == 0:
		return True
	elif yy % 100 == 0:
		return False
	elif yy % 4 == 0:
		return True
	else:
		return 0
for _ in range(int(stdin.readline())):
	(yy, mm, dd) = list(map(int, stdin.readline().split(':')))
	if mm in [1, 3, 5, 7, 8, 10, 12]:
		ans.append(str(int((31 - dd) / 2 + 1)))
	elif mm in [4, 6, 9, 11]:
		ans.append(str(int((30 - dd) / 2 + 16 + dd % 2)))
	else:
		ans.append(str(int((29 - dd) / 2 + 1) if leap_check(yy) else int((28 - dd) / 2 + 16 + dd % 2)))
stdout.write('\n'.join(ans))


def leap_year(x):
	if x % 400 == 0:
		return 1
	elif x % 100 == 0:
		return 0
	elif x % 4 == 0:
		return 1
	else:
		return 0
t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split(':'))
	p = y - 1
	count = 1
	a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	if leap_year(x):
		a[1] = 29
	if (y == 1 or y == 3 or y == 5 or (y == 7) or (y == 8) or (y == 10) or (y == 12)) or (y == 2 and a[1] == 29):
		count += (a[p] - z) // 2
	else:
		count += (a[p] + a[y] - z) // 2
	print(count)


import datetime
r = int(input())
for i in range(r):
	(a, b, c) = map(int, input().split(':'))
	b = datetime.datetime(a, b, c)
	y = 1
	z = c % 2
	while True:
		b += datetime.timedelta(days=2)
		if b.day % 2 != z:
			break
		y += 1
	print(y)


def isLeap(y):
	if y % 400 == 0:
		return True
	elif y % 100 == 0:
		return False
	elif y % 4 == 0:
		return True
	else:
		return False
t = int(input())
for i in range(t):
	d = input()
	(y, m, d) = d.split(':')
	y = int(y)
	m = int(m)
	d = int(d)
	if d % 2 == 0:
		if m not in [2, 4, 6, 9, 11]:
			print((31 - d) // 2 + 1)
		elif m != 2:
			print((30 - d) // 2 + 1 + 29 // 2 + 1)
		elif isLeap(y):
			print((29 - d) // 2 + 1)
		else:
			print((28 - d) // 2 + 1 + 29 // 2 + 1)
	elif m not in [2, 4, 6, 9, 11]:
		print((31 - d) // 2 + 1)
	elif m != 2:
		print((30 - d) // 2 + 1 + 31 // 2 + 1)
	elif isLeap(y):
		print((29 - d) // 2 + 1)
	else:
		print((28 - d) // 2 + 1 + 31 // 2 + 1)


import datetime
for _ in range(int(input())):
	(yy, mm, dd) = map(int, input().split(':'))
	d = dd % 2
	count = 1
	t = datetime.datetime(yy, mm, dd)
	while True:
		t = t + datetime.timedelta(days=2)
		if t.day % 2 != d:
			break
		else:
			count += 1
	print(count)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split(':'))
	if b in [1, 3, 5, 7, 8, 10, 12]:
		print(int((31 - c) / 2 + 1))
		continue
	if b in [4, 6, 9, 11]:
		print(int((61 - c) / 2 + 1))
		continue
	if a % 400 == 0 or (a % 100 != 0 and a % 4 == 0):
		print(int((29 - c) / 2 + 1))
		continue
	else:
		print(int((59 - c) / 2 + 1))
		continue


t = int(input())

def leapYear(Year):
	if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
		return True
	else:
		return False
for _ in range(t):
	s = input()
	a = s.split(':')
	year = int(a[0])
	m = int(a[1])
	d = int(a[2])
	if m == 2:
		if leapYear(year):
			print((29 - d) // 2 + 1)
		else:
			print((28 + 31 - d) // 2 + 1)
	if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
		print((31 - d) // 2 + 1)
	elif m == 4 or m == 6 or m == 9 or (m == 11):
		print((30 + 31 - d) // 2 + 1)


for _ in range(int(input())):
	x = input()
	(y, m, d) = (int(x[:4]), int(x[5:7]), int(x[8:]))
	if m in {1, 3, 5, 7, 8, 10, 12}:
		print((31 - d) // 2 + 1)
	elif m == 2:
		if y % 400 == 0 or (y % 4 == 0 and y % 100 != 0):
			print((29 - d) // 2 + 1)
		else:
			print((59 - d) // 2 + 1)
	else:
		print((61 - d) // 2 + 1)


days_per_month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
tests = int(input())
for i in range(tests):
	(year, month, day) = map(int, input().split(':'))
	if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
		days_per_month[2] = 29
	else:
		days_per_month[2] = 28
	right_time_intake = True
	ans = 0
	while right_time_intake:
		ans += 1
		curr_day = day
		day += 2
		if day > days_per_month[month]:
			day %= days_per_month[month]
			if curr_day % 2 != day % 2:
				right_time_intake = False
			else:
				month += 1
				if month == 13:
					month = 1
					year += 1
					if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
						days_per_month[2] = 29
					else:
						days_per_month[2] = 29
	print(ans)


def fun(year):
	if year % 4 == 0:
		if year % 100 == 0:
			if year % 400 == 0:
				return True
			else:
				return False
		else:
			return True
	else:
		return False
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
neven = [x // 2 for x in days]
nodd = [days[x] - neven[x] for x in range(12)]
days2 = days.copy()
days2[1] = 29
leven = [x // 2 for x in days2]
lodd = [days2[x] - leven[x] for x in range(12)]
for _ in range(int(input())):
	(y, m, d) = map(int, input().split(':'))
	ans = 0
	if fun(y):
		if days2[m - 1] % 2 == 0:
			if d % 2 == 0:
				print(leven[m - 1] - d // 2 + 1 + leven[m])
			else:
				print(lodd[m - 1] - d // 2 + lodd[m])
		elif d % 2 == 0:
			print(leven[m - 1] - d // 2 + 1)
		else:
			print(lodd[m - 1] - d // 2)
	elif days[m - 1] % 2 == 0:
		if d % 2 == 0:
			print(neven[m - 1] - d // 2 + 1 + neven[m])
		else:
			print(nodd[m - 1] - d // 2 + nodd[m])
	elif d % 2 == 0:
		print(neven[m - 1] - d // 2 + 1)
	else:
		print(nodd[m - 1] - d // 2)


t = int(input())
li1 = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
li2 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for z in range(t):
	(y, m, d) = list(map(int, input().split(':')))
	if y % 4 == 0:
		if y % 100 == 0:
			if y % 400 == 0:
				li = li1
			else:
				li = li2
		else:
			li = li1
	else:
		li = li2
	c = 0
	if d % 2 == 0:
		while d % 2 == 0:
			c += 1
			d += 2
			if d > li[m - 1]:
				d = d % li[m - 1]
				m += 1
	else:
		while d % 2 != 0:
			c += 1
			d += 2
			if d > li[m - 1]:
				d = d % li[m - 1]
				m += 1
	print(c)


import datetime as dt
testCases = int(input())
for testCase in range(testCases):
	(y, m, d) = map(int, input().split(':'))
	t = dt.datetime(y, m, d)
	c = 1
	while True:
		t += dt.timedelta(days=2)
		if t.day % 2 != d % 2:
			break
		else:
			c += 1
	print(c)


for _ in range(int(input())):
	EVEN = [4, 6, 9, 11]
	ODD = [1, 3, 5, 7, 8, 10, 12]
	(Y, M, D) = list(map(int, input().strip().split(':')))
	Ans = 0
	if Y % 400 == 0 or (Y % 4 == 0 and Y % 100 != 0):
		ODD.append(2)
		if M in EVEN:
			if D % 2 == 0:
				Ans = (30 - D) // 2 + 1 + 15
			else:
				Ans = (30 - D) // 2 + 1 + 16
		elif M in ODD:
			if D % 2 == 0:
				if M == 2:
					Ans = (29 - D) // 2 + 1
				else:
					Ans = (31 - D) // 2 + 1
			elif M == 2:
				Ans = (29 - D) // 2 + 1
			else:
				Ans = (31 - D) // 2 + 1
	else:
		EVEN.append(2)
		if M in ODD:
			if D % 2 == 0:
				Ans = (31 - D) // 2 + 1
			else:
				Ans = (31 - D) // 2 + 1
		elif M in EVEN:
			if D % 2 == 0:
				if M == 2:
					Ans = (28 - D) // 2 + 1 + 15
				else:
					Ans = (30 - D) // 2 + 1 + 15
			elif M == 2:
				Ans = (28 - D) // 2 + 1 + 16
			else:
				Ans = (30 - D) // 2 + 1 + 16
	print(Ans)