Read problems statements [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well.

Chef's planet is called Javad. A year on Javad has $N$ months numbered $1$ through $N$. For each valid $i$, the $i$-th month has $a_{i}$ days numbered $1$ through $a_{i}$. 

On Javad, years that are divisible by $4$ are leap years - the last month of each leap year is one day longer (it has $a_{N} + 1$ days).

You are given Chef's birth date and the current date. Find the age of Chef in days, i.e. the number of days between Chef's birth date and the current date inclusive.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains $N$ space-separated integers $a_{1}, a_{2}, \ldots, a_{N}$.
The third line contains three space-separated positive integers $y_{b}$, $m_{b}$ and $d_{b}$ denoting the year, month and day of Chef's birth respectively.
The fourth line contains three space-separated positive integers $y_{c}$, $m_{c}$ and $d_{c}$ denoting the current year, month and day respectively.

------  Output ------
For each test case, print a single line containing one integer — Chef's age in days.

------  Constraints  ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 10,000$
$1 ≤ a_{i} ≤ 10,000$ for each valid $i$
$1 ≤ y_{b}, y_{c} ≤ 100,000$
$1 ≤ m_{b}, m_{c} ≤ N$
$d_{b}$ will be less than or equal to the days of the $m_{b}$ month of the $y_{b}$ year.
$d_{c}$ will be less than or equal to the days of the $m_{c}$ month of the $y_{c}$ year.
the current date is equal to or greater than Chef's birth date

------  Subtasks ------
Subtask #1 (10 points):
$1 ≤ y_{b}, y_{c}, N ≤ 1,000$
$1 ≤ a_{i} ≤ 100$ for each valid $i$

Subtask #2 (90 points): original constraints

----- Sample Input 1 ------ 
4

5

1 2 3 4 5

2 1 1

3 5 1

2

3 3

1 1 1

2 2 2

2

1 1

3 1 1

3 2 1

5

1 4 3 4 6

3 5 6

10 1 1
----- Sample Output 1 ------ 
26

11

2

112

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Implementation


Solutions:
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(yb, mb, db) = list(map(int, input().split()))
	(yc, mc, dc) = list(map(int, input().split()))
	if yc == yb:
		if mc == mb:
			print(dc - db + 1)
		else:
			ans = a[mb - 1] - db + 1 + sum(a[mb:mc - 1]) + dc
			print(ans)
	else:
		first = a[mb - 1] - db + 1 + sum(a[mb:])
		middle = sum(a) * (yc - yb - 1)
		current = sum(a[:mc - 1]) + dc
		ans = first + middle + current
		ans += (yc - yb) // 4
		for j in range((yc - yb) % 4):
			if (yc - 1 - j) % 4 == 0:
				ans += 1
				break
		print(ans)


def days_since_birth(n, months, y_b, m_b, d_b, y_c, m_c, d_c):
	if y_c == y_b and m_c == m_b and (d_c == d_b):
		return 1
	elif y_c == y_b and m_c == m_b:
		return d_c - d_b + 1
	elif y_c == y_b:
		return months[m_b - 1] - d_b + 1 + d_c + sum(months[m_b:m_c - 1])
	result = (y_c - y_b - 1) * sum(months)
	result += sum(months[m_b:])
	result += sum(months[:m_c - 1])
	result += months[m_b - 1] - d_b + 1
	result += d_c
	for i in range(y_b, y_c):
		if i % 4 == 0:
			result += 1
	return result
for _ in range(int(input())):
	print(days_since_birth(int(input()), list(map(int, input().split())), *map(int, input().split()), *map(int, input().split())))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(yb, mb, db) = map(int, input().split())
	age_d = 0
	(yc, mc, dc) = map(int, input().split())
	no = sum(a)
	le = no + 1
	for j in range(yb, yc):
		if j % 4 == 0:
			age_d = age_d + le
		else:
			age_d = age_d + no
	age_d = age_d - (sum(a[0:mb - 1]) + db) + (sum(a[0:mc - 1]) + dc)
	print(age_d + 1)


t = int(input())
j = 0
while j < t:
	n = int(input())
	leap = 0
	a = [int(i) for i in input().split()]
	(y1, m1, d1) = map(int, input().split())
	(y2, m2, d2) = map(int, input().split())
	if y1 != y2:
		days = a[m1 - 1] - d1 + d2 + 1
		for i in range(m1, n):
			days = days + a[i]
		for i in range(0, m2 - 1):
			days = days + a[i]
		days = days + sum(a) * (y2 - y1 - 1)
		i = y1
		while i < y2:
			if i % 4 == 0:
				leap = leap + 1
			i = i + 1
	elif m1 == m2:
		if d1 == d2:
			days = 1
		else:
			days = d2 - d1 + 1
	else:
		days = a[m1 - 1] - d1 + d2 + 1
		for i in range(m1, m2 - 1):
			days = days + a[i]
	print(days + leap)
	j = j + 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(a, b, c) = map(int, input().split())
	(d, e, f) = map(int, input().split())
	s = f - c
	if b <= e:
		s += sum(l[b - 1:e - 1])
	else:
		s -= sum(l[e - 1:b - 1])
	z = d % 4
	if z == 0:
		z = 4
	if z <= (d - a) % 4:
		s += 2
	else:
		s += 1
	s += (d - a) // 4
	s += sum(l) * (d - a)
	print(s)


def ti():
	return tuple(map(int, input().split()))

def li():
	return list(map(int, input().split()))

def si():
	return input().split()

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

def ip():
	return input()

def year2days(y, a):
	return sum(a) * (y - 1) + (y - 1) // 4

def month2days(m, a):
	return sum(a[:m - 1])
for tastcas in range(int(input())):
	n = ii()
	arr = li()
	(a1, b1, c1) = li()
	(a2, b2, c2) = li()
	birth = year2days(a1, arr) + month2days(b1, arr) + c1
	current = year2days(a2, arr) + month2days(b2, arr) + c2
	print(current - birth + 1)


def year2days(y, arr):
	s = 0
	for i in arr:
		s += i
	s *= y - 1
	s += (y - 1) // 4
	return s

def month2days(m, arr):
	s = 0
	for i in range(m - 1):
		s += arr[i]
	return s
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	[a, b, c] = map(int, input().split())
	birth = year2days(a, arr) + month2days(b, arr) + c
	[a, b, c] = map(int, input().split())
	current = year2days(a, arr) + month2days(b, arr) + c
	print(current - birth + 1)


t = int(input())
for i in range(t):
	n = int(input())
	c = 0
	a = list(map(int, input().split()))
	(y1, m1, d1) = map(int, input().split())
	(y2, m2, d2) = map(int, input().split())
	if y1 != y2:
		d = a[m1 - 1] - d1 + d2 + 1
		for j in range(m1, n):
			d += a[j]
		for k in range(m2 - 1):
			d += a[k]
		d += sum(a) * (y2 - y1 - 1)
		s = y1
		while s < y2:
			if s % 4 == 0:
				c += 1
			s += 1
	elif m1 == m2:
		if d1 == d2:
			d = 1
		else:
			d = d2 - d1 + 1
	else:
		d = a[m1 - 1] - d1 + d2 + 1
		for z in range(m1, m2 - 1):
			d += a[z]
	print(d + c)


def cal(current, goal):
	count = 0
	for i in range(current, goal):
		if i % 4 == 0:
			count += 1
	return count

def cal1(arr, month, day):
	sum = 0
	for i in range(month - 1):
		sum += arr[i]
	return sum + day

def cal2(arr, month, day):
	days_of_month = 0
	for i in range(month, len(arr)):
		days_of_month += arr[i]
	days = arr[month - 1] - day + 1
	return days + days_of_month
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	days_in_1year = sum(lis)
	(yb, mb, db) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	leap_count = cal(yb, yc)
	year_count = max(0, yc - yb - 1)
	year_days = year_count * days_in_1year
	current_year_count = cal1(lis, mc, dc)
	if yb != yc:
		last_year_count = cal2(lis, mb, db)
		current_year_count = cal1(lis, mc, dc)
		print(current_year_count + year_days + leap_count + last_year_count)
	else:
		last_year_count = cal1(lis, mb, db)
		current_year_count = cal1(lis, mc, dc)
		print(current_year_count + year_days + leap_count - last_year_count + 1)


import math
t = int(input())
for tt in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	(yb, mb, db) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	presum = [0] * n
	presum[0] = arr[0]
	for i in range(1, n):
		presum[i] = presum[i - 1] + arr[i]
	ans = 0
	if yb == yc:
		if mb == mc:
			if db == dc:
				ans = 1
			else:
				ans = abs(dc - db) + 1
		else:
			ans += arr[mb - 1] - db + 1
			ans += dc
			ans += presum[mc - 1] - presum[mb - 1] - arr[mc - 1]
	else:
		ans += (yc - yb - 1) * presum[n - 1]
		ans += presum[n - 1] - presum[mb - 1]
		ans += arr[mb - 1] - db + 1
		ans += presum[mc - 1] - arr[mc - 1]
		ans += dc
		for i in range(yb, yc):
			if i % 4 == 0:
				ans += 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	sum1 = 0
	sum2 = 0
	days = [int(x) for x in input().split()]
	(y, m, d) = (int(x) for x in input().split())
	(y_1, m_1, d_1) = (int(x) for x in input().split())
	ans = 0
	ans += y_1 // 4 - y // 4
	if y_1 % 4 == 0:
		ans -= 1
	sum1 += y * sum(days) + sum(days[0:m - 1]) + d
	sum2 += y_1 * sum(days) + sum(days[0:m_1 - 1]) + d_1
	if y % 4 == 0:
		sum2 += 1
	print(sum2 - sum1 + 1 + ans)


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	(yb, mb, db) = map(int, input().split())
	k = 0
	(yc, mc, dc) = map(int, input().split())
	no = sum(a)
	le = no + 1
	for j in range(yb, yc):
		if j % 4 == 0:
			k = k + le
		else:
			k = k + no
	k = k - sum(a[0:mb - 1]) - db
	k = k + sum(a[0:mc - 1]) + dc
	print(k + 1)


def daysfrombeg(d, m, y, sumy):
	count = 0
	lep = (y - 1) // 4
	nolep = y - 1 - lep
	count += lep * (sumy + 1)
	count += nolep * sumy
	return count
t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	arr = []
	sumo = 0
	for i in range(n):
		sumo += li[i]
		arr.append(sumo)
	l = input().split()
	y = int(l[0])
	m = int(l[1])
	d = int(l[2])
	numofday1 = daysfrombeg(d, m, y, sumo)
	if m >= 2:
		numofday1 += arr[m - 2]
	numofday1 += d
	l = input().split()
	y = int(l[0])
	m = int(l[1])
	d = int(l[2])
	numofday2 = daysfrombeg(d, m, y, sumo)
	if m >= 2:
		numofday2 += arr[m - 2]
	numofday2 += d
	print(numofday2 - numofday1 + 1)


T = int(input())
for i in range(T):
	N = int(input())
	L = list(map(int, input().split()))
	(yb, mb, db) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	days = 0
	for i in range(yb + 1, yc):
		days += sum(L)
		if i % 4 == 0:
			days += 1
	if yb != yc:
		if mb == N:
			days += L[mb - 1] - db + 1
		else:
			for j in range(mb, N):
				days += L[j]
			days += L[mb - 1] - db + 1
		for u in range(mc - 1):
			days += L[u]
		days += dc
	elif mb != mc:
		for k in range(mb, mc - 1):
			days += L[k]
		days += L[mb - 1] - db + 1 + dc
	else:
		days += dc - db + 1
	if yb % 4 == 0 and yb != yc:
		days += 1
	print(days)


def main():
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		arr1 = [arr[0]]
		for i in range(1, n):
			arr1.append(arr1[i - 1] + arr[i])
		(yb, mb, db) = map(int, input().split())
		(yc, mc, dc) = map(int, input().split())
		if mb == 1:
			late_birth = db
		else:
			late_birth = arr1[mb - 2] + db
		if mc == 1:
			extra_date = dc
		else:
			extra_date = arr1[mc - 2] + dc
		no_days = (yc - yb) * arr1[-1] + 1
		no_days += extra_date
		no_days -= late_birth
		leep = yc // 4 - yb // 4
		if yb % 4 == 0:
			leep += 1
		if yc % 4 == 0:
			leep -= 1
		print(no_days + leep)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	str_arr = input().split(' ')
	arr = [int(i) for i in str_arr]
	str_arr = input().split(' ')
	(y1, m1, d1) = (int(str_arr[0]), int(str_arr[1]), int(str_arr[2]))
	str_arr = input().split(' ')
	(y2, m2, d2) = (int(str_arr[0]), int(str_arr[1]), int(str_arr[2]))
	full_year = sum(arr)
	num_leap_year = 0
	for i in range(y1, y2):
		if i % 4 == 0:
			num_leap_year += 1
	cnt = 0
	cnt += (y2 - y1) * full_year + num_leap_year + 1
	start = min(m1, m2) - 1
	end = max(m1, m2) - 1
	if m2 > m1:
		cnt += sum(arr[start:end])
	else:
		cnt -= sum(arr[start:end])
	cnt += d2 - d1
	print(cnt)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	(y1, m1, d1) = map(int, input().split())
	(y2, m2, d2) = map(int, input().split())
	m1 = m1 - 1
	m2 = m2 - 1
	x = (y2 - y1 - 1) * sum(l) + (l[m1] - d1 + 1) + sum(l[m1 + 1:]) + sum(l[0:m2]) + d2
	for i in range(y1, y2):
		if i % 4 == 0:
			x += 1
	print(x)


T = int(input())
for _ in range(T):
	N = int(input())
	M = list(map(int, input().split()))
	I = list(map(int, input().split()))
	F = list(map(int, input().split()))
	yeartime = 0
	for i in M:
		yeartime += i
	yearday = (F[0] - I[0]) * yeartime
	i = 0
	m1 = 0
	while i != I[1] - 1:
		m1 += M[i]
		i += 1
	i = 0
	m2 = 0
	while i != F[1] - 1:
		m2 += M[i]
		i += 1
	totalday = m2 + F[2] + 1 + yearday - (m1 + I[2])
	i = I[0]
	while i % 4 != 0:
		i += 1
	count = 0
	while i < F[0]:
		count += 1
		i += 4
	totalday += count
	print(totalday)


k = int(input())
for i in range(k):
	n = int(input())
	u = 0
	a = list(map(int, input().split()))
	(x, y, z) = map(int, input().split())
	(p, q, r) = map(int, input().split())
	if x == p:
		u = sum(a[y - 1:q - 1]) - (z - 1) + r
	else:
		for j in range(x, p + 1):
			if j == x:
				u = u + sum(a[y - 1:]) - (z - 1)
				if j % 4 == 0:
					u = u + 1
			if j == p:
				u = u + sum(a[0:q - 1]) + r
			if j != p and j != x:
				u = u + sum(a)
				if j % 4 == 0:
					u = u + 1
	print(u)


T = int(input())
while T > 0:
	n = int(input())
	a = list(map(int, input().split()))
	(yb, mb, db) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	asum = sum(a)
	day = a[mb - 1] - db + 1
	i = mb
	while i < n:
		day += a[i]
		i += 1
	if yb % 4 == 0:
		day += 1
	yb += 1
	minus = a[mc - 1] - dc
	i = mc
	while i < n:
		minus += a[i]
		i += 1
	if yc % 4 == 0:
		minus += 1
	day += asum * (yc - yb + 1)
	day += yc // 4 - yb // 4
	if yb % 4 == 0:
		day += 1
	day -= minus
	print(day)
	T -= 1


t = int(input())

def countLeap(a, b):
	count = 0
	for i in range(a, b + 1):
		if i % 4 == 0:
			count += 1
	return count

def countdays(y1, y2, a):
	if y2 >= y1:
		noleap = sum(a)
		leap = noleap + 1
		return countLeap(y1, y2) * leap + (y2 - y1 + 1 - countLeap(y1, y2)) * noleap
	else:
		return 0

def birthval(y, m, d, a):
	dur = sum(a)
	sumi = 0
	for i in range(0, m - 1, 1):
		sumi += a[i]
	ans = dur - sumi - d + 2
	if y % 4 == 0:
		return ans
	else:
		return ans - 1

def endval(y, m, d, a):
	sumI = 0
	for i in range(0, m - 1, 1):
		sumI += a[i]
	return sumI + d
for _ in range(t):
	n = int(input())
	a = []
	a = list(map(int, input().split()))
	(yb, mb, db) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	if yc > yb:
		x = birthval(yb, mb, db, a)
		y = endval(yc, mc, dc, a)
		z = countdays(yb + 1, yc - 1, a)
		print(x + y + z)
	else:
		y = endval(yc, mc, dc, a)
		z = endval(yb, mb, db, a)
		print(1 + y - z)


t = int(input())
for i in range(0, t):
	n = int(input())
	l = list(map(int, input().split()))
	(y1, m1, d1) = list(map(int, input().split()))
	(y2, m2, d2) = list(map(int, input().split()))
	sum = 0
	l1 = []
	tot = 0
	for j in range(0, n):
		sum += l[j]
		l1.append(sum)
	j = y1
	lp = 0
	while j < y2:
		if j % 4 == 0:
			lp += 1
		j += 1
	tot = sum * (y2 - y1 - 1) + lp
	tot += sum - l1[m1 - 1] + l[m1 - 1] - d1 + 1
	tot += l1[m2 - 1] - l[m2 - 1] + d2
	print(tot)


t = int(input())
while t:
	n = int(input())
	months = [int(w) for w in input().split()]
	(yb, mb, db) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	if yb == yc:
		if yb % 4 == 0:
			months[n - 1] = months[n - 1] + 1
		if mb == mc:
			print(dc - db + 1)
		else:
			total = months[mb - 1] - db + 1
			for i in range(mb, mc - 1):
				total = total + months[i]
			total = total + dc
			print(total)
	else:
		total = 0
		for i in range(yb, yc + 1):
			cmonth = []
			cmonth = months[:]
			if i % 4 == 0:
				cmonth[n - 1] = cmonth[n - 1] + 1
			if i == yb:
				total = cmonth[mb - 1] - db + 1
				for j in range(mb, n):
					total = total + cmonth[j]
			if i != yb and i != yc:
				total = total + sum(cmonth)
			if i == yc:
				for j in range(0, mc - 1):
					total = total + cmonth[j]
				total = total + dc
		print(total)
	t = t - 1


def dey(y, m, d, a):
	daysIn = y * sum(a)
	daysIn += (y - 1) // 4
	for i in range(0, m):
		daysIn += a[i]
	return daysIn + d
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	(yb, mb, db) = map(int, input().split(' '))
	(yc, mc, dc) = map(int, input().split(' '))
	mb -= 1
	mc -= 1
	print(dey(yc, mc, dc, a) - dey(yb, mb, db, a) + 1)


for i in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	(yb, mb, db) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	year = sum(a)
	total = (yc - yb - 1) * year
	for j in range(yb, yc):
		if j % 4 == 0:
			total += 1
	total = total + a[mb - 1] - db + dc
	for j in range(mb, N):
		total += a[j]
	for j in range(mc - 1):
		total += a[j]
	print(total + 1)


t = int(input())
for _ in range(t):
	n = int(input())
	m = list(map(int, input().strip().split()))
	(yb, mb, db) = map(int, input().strip().split())
	(yc, mc, dc) = map(int, input().strip().split())
	s = sum(m)
	d = 0
	if yb != yc:
		for i in range(yb + 1, yc):
			if i % 4 == 0:
				d += s + 1
			else:
				d += s
		if yb % 4 == 0:
			m[n - 1] += 1
		for i in range(mb, n):
			d += m[i]
		d += m[mb - 1] - db + 1
		if yc % 4 != 0 and yb % 4 == 0:
			m[n - 1] -= 1
		for i in range(mc - 1):
			d += m[i]
		d += dc
	else:
		if yc % 4 == 0:
			m[n - 1] += 1
		for i in range(mb, mc - 1):
			d += m[i]
		if mb != mc:
			d += m[mb - 1] - db + 1
			d += dc
		else:
			d = dc - db + 1
	print(d)


T = int(input())
for i in range(T):
	N = int(input())
	A = input().split()
	(yb, mb, db) = input().split()
	(yc, mc, dc) = input().split()
	days = 0
	for j in range(N):
		days += int(A[j])
	count = 0
	for k in range(int(yb), int(yc)):
		if k % 4 == 0:
			count += 1
	days1 = (int(yc) - int(yb) - 1) * days + count
	days2 = 0
	for x in range(int(mc) - 1):
		days2 += int(A[x])
	days2 += int(dc)
	days3 = 0
	for y in range(int(mb) - 1, N):
		days3 += int(A[y])
	days3 -= int(db)
	print(days1 + days2 + days3 + 1)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	c = sum(a)
	bd = [int(x) for x in input().split()]
	cd = [int(x) for x in input().split()]
	sum1 = 0
	if bd[0] == cd[0]:
		if bd[1] == cd[1]:
			if bd[2] == cd[2]:
				sum1 += 1
			else:
				sum1 = sum1 + cd[2] - bd[2] + 1
		else:
			sum1 = sum1 + a[bd[1] - 1] - bd[2] + 1
			for y in range(bd[1], cd[1] - 1):
				sum1 += a[y]
			sum1 += cd[2]
	else:
		for x in range(bd[0], cd[0]):
			if x == bd[0]:
				sum1 = sum1 + a[bd[1] - 1] - bd[2] + 1
				for y in range(bd[1], n):
					sum1 = sum1 + a[y]
			else:
				sum1 = sum1 + c
				if x % 4 == 0:
					sum1 += 1
		sum1 = sum1 + sum(a[0:cd[1] - 1]) + cd[2]
	if bd[0] % 4 == 0 and bd[0] != cd[0]:
		sum1 = sum1 + 1
	print(sum1)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	dob = list(map(int, input().split()))
	cd = list(map(int, input().split()))
	cum_list = []
	cum_list.append(0)
	cum_list.append(arr[0])
	days_in_year = 0
	for (i, x) in enumerate(arr):
		if i != 0:
			cum_list.append(arr[i] + cum_list[i])
		days_in_year += x
	leap_year_passed_since_birth = int((dob[0] - 1) / 4)
	leap_year_passed_till_date = int((cd[0] - 1) / 4)
	age_in_days = leap_year_passed_since_birth * (days_in_year + 1) + (dob[0] - 1 - leap_year_passed_since_birth) * days_in_year + cum_list[dob[1] - 1] + dob[2]
	date_in_days = leap_year_passed_till_date * (days_in_year + 1) + (cd[0] - 1 - leap_year_passed_till_date) * days_in_year + cum_list[cd[1] - 1] + cd[2]
	print(date_in_days - age_in_days + 1)


t = int(input())
for i in range(t):
	n = int(input())
	d = [int(i) for i in input().split()]
	(yb, mb, db) = [int(i) for i in input().split()]
	(yc, mc, dc) = [int(i) for i in input().split()]
	v = d[-1]
	c = 0
	if yb % 4 == 0:
		d[-1] = v + 1
	if yb == yc:
		if mb == mc:
			c += dc - db + 1
		else:
			c += d[mb - 1] - db + 1
			c += sum(d[mb:mc - 1])
			c += dc
	else:
		c += d[mb - 1] - db + 1
		c += sum(d[mb:])
		for i in range(yb + 1, yc):
			if i % 4 == 0:
				d[-1] = v + 1
			else:
				d[-1] = v
			c += sum(d)
		c += sum(d[:mc - 1])
		c += dc
	print(c)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(yb, mb, db) = list(map(int, input().split()))
	(yc, mc, dc) = list(map(int, input().split()))
	print((yc - yb) * sum(arr) + yc // 4 - yb // 4 - (yc % 4 == 0) + (yb % 4 == 0) + sum(arr[:mc - 1]) - sum(arr[:mb - 1]) + dc - db + 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	birth = list(map(int, input().split()))
	cur = list(map(int, input().split()))
	days = sum(a)
	(bdays, curdays) = (0, 0)
	bdays = (birth[0] - 1) * days + sum(a[:birth[1] - 1]) + birth[2] + (birth[0] - 1) // 4
	curdays = (cur[0] - 1) * days + sum(a[:cur[1] - 1]) + cur[2] + (cur[0] - 1) // 4
	print(curdays - bdays + 1)


def calcDays(d, m, y, arr):
	numDays = 0
	if y % 4 == 0:
		numDays += y // 4 * (sum(arr) + 1)
		numDays += (y - y // 4) * sum(arr)
	else:
		numDays += (y // 4 + 1) * (sum(arr) + 1)
		numDays += (y - y // 4 - 1) * sum(arr)
	for i in range(m):
		if i == m - 1:
			numDays += d
			break
		numDays += arr[i]
	return numDays
tc = int(input())
for i in range(tc):
	n = int(input())
	arr = list(map(int, input().split()))
	birthDate = list(map(int, input().split()))
	currDate = list(map(int, input().split()))
	calcBirthDays = calcDays(birthDate[2], birthDate[1], birthDate[0], arr)
	calcCurrDays = calcDays(currDate[2], currDate[1], currDate[0], arr)
	print(calcCurrDays - calcBirthDays + 1)


for _ in range(int(input())):
	n = int(input())
	days = list(map(int, input().strip().split()))
	birth = list(map(int, input().strip().split()))
	current = list(map(int, input().strip().split()))
	sumdays = sum(days)
	daysborn = 0
	dayscurr = 0
	daysborn += (birth[0] - 1) * sumdays + sum(days[:birth[1] - 1]) + birth[2] + (birth[0] - 1) // 4
	dayscurr += (current[0] - 1) * sumdays + sum(days[:current[1] - 1]) + current[2] + (current[0] - 1) // 4
	daycount = dayscurr - daysborn + 1
	print(daycount)


def leapcheck(y):
	if y % 4 == 0:
		return 1
	else:
		return 0

def nod(y, n, a):
	nod = 0
	for z in range(n):
		nod += a[z]
	nod += leapcheck(y)
	return nod

def daysfrom0(y, m, d, n, a):
	nods = 0
	if y != 0:
		for x in range(y):
			nods += nod(x, n, a)
	for z in range(m - 1):
		nods += a[z]
	nods += d
	return nods
for x in range(int(input())):
	n = int(input())
	a = [int(y) for y in input().split()]
	b = [int(y) for y in input().split()]
	yb = b[0]
	mb = b[1]
	db = b[2]
	c = [int(y) for y in input().split()]
	yc = c[0]
	mc = c[1]
	dc = c[2]
	birthday = daysfrom0(yb, mb, db, n, a)
	currentday = daysfrom0(yc, mc, dc, n, a)
	print(currentday + 1 - birthday)


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	k = list(map(int, input().split()))
	m = list(map(int, input().split()))
	d = (k[0] - 1) * sum(l) + sum(l[:k[1] - 1]) + k[2]
	d += (k[0] - 1) // 4
	e = (m[0] - 1) * sum(l) + sum(l[:m[1] - 1]) + m[2]
	e += (m[0] - 1) // 4
	i = k[0]
	print(e - d + 1)


for i in range(int(input())):
	nmy = int(input())
	dim = list(map(int, input().strip().split()))
	(yb, mb, db) = map(int, input().strip().split())
	(yc, mc, dc) = map(int, input().strip().split())
	nd = sum(dim)
	age = (yc - yb - 1) * nd
	if yb % 4 == 0:
		s = yb
	else:
		s = yb - yb % 4 + 4
	while s < yc:
		age += 1
		s += 4
	age += dim[mb - 1] - db + 1
	if mb != nmy:
		age += sum(dim[mb:])
	age += dc
	if mc != 1:
		age += sum(dim[:mc - 1])
	print(age)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(yb, mb, db) = list(map(int, input().split()))
	(yc, mc, dc) = list(map(int, input().split()))
	ndy = sum(arr)
	nly = yb // 4 - (yb % 4 == 0)
	daysb = (yb - 1) * ndy + nly
	for i in range(mb - 1):
		daysb += arr[i]
	daysb += db
	nly = yc // 4 - (yc % 4 == 0)
	daysc = (yc - 1) * ndy + nly
	for i in range(mc - 1):
		daysc += arr[i]
	daysc += dc
	print(daysc - daysb + 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(yb, mb, db) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	ans = 0
	if yb == yc and mb == mc:
		print(dc - db + 1)
	elif yb == yc:
		ans = 0
		ans += a[mb - 1] - db + 1
		for i in range(mb, mc - 1):
			ans += a[i]
		ans += dc
		print(ans)
	else:
		ans = 0
		ans += a[mb - 1] - db + 1
		ans += dc
		for i in range(mb, n):
			ans += a[i]
		for i in range(mc - 1):
			ans += a[i]
		ans += (yc - yb - 1) * sum(a)
		for i in range(yb, yc):
			if i % 4 == 0:
				ans += 1
		print(ans)


T = int(input())
for i in range(0, T):
	add = 0
	count = 0
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	for j in range(0, C[0] - B[0]):
		for x in range(0, len(A)):
			add += A[x]
	for k in range(0, B[1] - 1):
		add -= A[k]
	for h in range(0, C[1] - 1):
		add += A[h]
	for h in range(B[0], C[0]):
		if h % 4 == 0:
			count += 1
	print(add - B[-1] + C[-1] + count + 1)


def main():
	t = int(input())
	for j in range(t):
		n = int(input())
		a = [int(item) for item in input().split()]
		(yb, mb, db) = [int(item) for item in input().split()]
		(yc, mc, dc) = [int(item) for item in input().split()]
		dby = a[mb - 1] - db + 1 + sum(a[mb:])
		if yb % 4 == 0:
			dby += 1
		if mc == 1:
			dbc = dc
		else:
			dbc = sum(a[:mc - 1]) + dc
		if yb == yc:
			if mb == mc:
				total = dc - db + 1
			else:
				total = a[mb - 1] - db + 1 + sum(a[mb:mc - 1]) + dc
		else:
			ybl = yb + 1
			ycl = yc - 1
			if ybl % 4 == 0:
				s = ybl // 4
			else:
				s = ybl // 4 + 1
			e = ycl // 4
			leapyears = e - s + 1
			restyears = ycl - ybl - leapyears + 1
			restdays = sum(a)
			leapdays = restdays + 1
			total = restdays * restyears + leapdays * leapyears + dby + dbc
		print(total)
	return 0
main()


t = int(input())
for x in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	l = a.copy()
	(y1, m1, d1) = map(int, input().split())
	(y2, m2, d2) = map(int, input().split())
	lp = int((y2 - y2 % 4 - (y1 + (4 - y1 % 4))) / 4)
	if y2 % 4 == 0:
		lp = lp
	else:
		lp = lp + 1
	s = 0
	days = 0
	for i in range(0, len(l)):
		s = s + l[i]
		l[i] = s
	days = (y2 - y1 - 1) * l[len(l) - 1]
	days = days + l[len(l) - 1] - l[m1 - 1] + (a[m1 - 1] - d1)
	days = days + l[m2 - 2] % l[len(l) - 1] + d2
	if y1 % 4 == 0:
		days = days + 1
	print(days + 1 + lp)


from math import ceil
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(y, m, d) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	s = []
	c = 0
	t = 0
	for i in a:
		c += i
		s.append(c)
	if yc - y >= 2:
		for i in range(y + 1, yc):
			t += s[n - 1]
			if i % 4 == 0:
				t += 1
		t += s[n - 1] - s[m - 1] + a[m - 1] - d + 1
		if y % 4 == 0:
			t += 1
		if mc > 1:
			t += s[mc - 2]
		t += dc
		print(t)
	elif yc - y == 1:
		t += s[n - 1] - s[m - 1] + a[m - 1] - d + 1
		if y % 4 == 0:
			t += 1
		if mc > 1:
			t += s[mc - 2]
		t += dc
		print(t)
	else:
		if mc == m:
			t = dc - d + 1
		else:
			t = s[mc - 2] - s[m - 1] + a[m - 1] - d + 1 + dc
		print(t)


t = int(input())
for z in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	yb = list(map(int, input().split()))
	yc = list(map(int, input().split()))
	(x, li) = (0, [])
	s = sum((e for e in a))
	li.append(0)
	for ele in a:
		x = x + ele
		li.append(x)
	d1 = int(yb[0]) * s + li[int(yb[1]) - 1] + int(yb[2])
	d2 = int(yc[0]) * s + li[int(yc[1]) - 1] + int(yc[2])
	x = yb[0] // 4
	if yb[0] % 4 == 0:
		x -= 1
	y = yc[0] // 4
	if yc[0] % 4 == 0:
		y -= 1
	print(d2 - d1 + 1 + y - x)


for _ in range(int(input())):
	n = int(input())
	arr = [int(d) for d in input().split()]
	(y1, m1, d1) = [int(d) for d in input().split()]
	(y2, m2, d2) = [int(d) for d in input().split()]
	days = sum(arr)
	count = 0
	for s in range(y1 + 1, y2):
		if s % 4 == 0:
			count += 1
	if y1 != y2:
		a = sum(arr[m1 - 1:]) - d1 + 1
		b = sum(arr[0:m2]) - arr[m2 - 1] + d2
		if y1 % 4 == 0:
			a += 1
		print((y2 - y1 - 1) * days + a + b + count)
	else:
		a = sum(arr[m1 - 1:m2 - 1]) - d1 + d2 + 1
		print(a)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(y, m, d) = map(int, input().split())
	(yy, mm, dd) = map(int, input().split())
	ly = 0
	for year in range(y, yy):
		if year % 4 == 0:
			ly = year
			break
	if ly > 0:
		ly = (yy - 1 - ly) // 4 + 1
	totaldays = sum(a) * (yy - y) + ly
	start = d - 1
	if m > 1:
		for i in range(m - 1):
			start += a[i]
	end = dd
	if mm > 1:
		for i in range(mm - 1):
			end += a[i]
	print(totaldays - start + end)


raw_input = input
for _ in range(int(raw_input())):
	n = int(raw_input())
	A = [int(x) for x in raw_input().split()]
	(yb, mb, db) = map(int, raw_input().split())
	(yc, mc, dc) = map(int, raw_input().split())
	tot_days = sum(A)
	ans = (yc - yb - 1) * tot_days
	if ans < 0:
		ans = 0
	if yc == yb and mc == mb:
		ans += dc - db + 1
	elif yc == yb:
		ans += dc + A[mb - 1] - db + 1
		for i in range(mb, mc - 1):
			ans += A[i]
	else:
		ans += A[mb - 1] - db + 1
		for i in range(mb, n):
			ans += A[i]
		ans += dc
		for i in range(mc - 1):
			ans += A[i]
		for i in range(yb, yc):
			if i % 4 == 0:
				ans += 1
	print(ans)


T = int(input())
for i in range(T):
	N = int(input())
	x = 0
	y = 0
	z = 0
	a = list(map(int, input().split()))
	(y1, m1, d1) = map(int, input().split())
	(y2, m2, d2) = map(int, input().split())
	for j in range(N):
		x = x + a[j]
	for j in range(m1 - 1):
		y = y + a[j]
	for j in range(m2 - 1):
		z = z + a[j]
	for j in range(1, y1):
		if j % 4 == 0:
			y = y + 1
	for j in range(1, y2):
		if j % 4 == 0:
			z = z + 1
	l = (y1 - 1) * x + y + d1
	m = (y2 - 1) * x + z + d2
	print(m - l + 1)


def isleapyear(n):
	if n % 4 == 0:
		return True
	return False
for _ in range(int(input())):
	m = int(input())
	dom = list(map(int, input().split()))
	doy = sum(dom)
	(by, bm, bd) = map(int, input().split())
	(ny, nm, nd) = map(int, input().split())
	days = 0
	if by != ny:
		for i in range(by, ny):
			if isleapyear(i):
				days += doy + 1
			else:
				days += doy
	dayTYear = bd + sum(dom[0:bm - 1])
	dayCYear = nd + sum(dom[0:nm - 1])
	days += dayCYear - dayTYear
	print(days + 1)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	(yb, mb, db) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	year = sum(a)
	age = 0
	bd = 0
	for i in range(mb - 1):
		bd += a[i]
	bd += db
	cd = 0
	for i in range(mc - 1):
		cd += a[i]
	cd += dc
	for i in range(yb, yc):
		if i % 4 == 0:
			age += year + 1
		else:
			age += year
	age += cd - bd
	age += 1
	print(age)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	(year1, month1, day1) = map(int, input().split())
	(year2, month2, day2) = map(int, input().split())
	if year1 != year2:
		year_diff = year2 - year1 - 1
		days1 = l[month1 - 1] - day1 + 1 + sum(l[month1:])
		if year1 % 4 == 0:
			days1 += 1
		days2 = day2 + sum(l[:month2 - 1])
		leap_year = 0
		if year1 % 4 == 0 and year2 % 4 == 0 or (year1 % 4 != 0 and year2 % 4 == 0):
			leap_year = max(year2 // 4 - year1 // 4 - 1, 0)
		if year1 % 4 == 0 and year2 % 4 != 0 or (year1 % 4 != 0 and year2 % 4 != 0):
			leap_year = year2 // 4 - year1 // 4
		days = leap_year + year_diff * sum(l) + days1 + days2
		print(days)
	else:
		a = 0
		if month1 != month2:
			a = sum(l[month1:month2 - 1]) + l[month1 - 1] - day1 + 1 + day2
		else:
			a = day2 - day1 + 1
		print(a)


from itertools import accumulate
R = lambda : map(int, input().split())

def age(t):
	(y, m, d) = t
	return y * a[-1] + (y - 1) // 4 + a[m - 1] + d
t = int(input())
for _ in range(t):
	input()
	a = [0, *accumulate(R())]
	(b, c) = (R(), R())
	print(age(c) - age(b) + 1)


for i in range(int(input())):
	n = int(input())
	A = [int(x) for x in input().split()]
	(yb, mb, db) = input().split()
	(yc, mc, dc) = input().split()
	yb = int(yb)
	mb = int(mb)
	db = int(db)
	yc = int(yc)
	mc = int(mc)
	dc = int(dc)
	t = sum(A)
	d = 0
	for j in range(mb - 1):
		d = d + A[j]
	x = t * yb + d + db + int((yb - 1) / 4)
	d = 0
	for j in range(mc - 1):
		d = d + A[j]
	y = t * yc + d + dc + int((yc - 1) / 4)
	print(y - x + 1)


for t in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	A.insert(0, 0)
	(yb, mb, db) = map(int, input().split())
	(yc, mc, dc) = map(int, input().split())
	sumc = (yc - 1) * sum(A) + (yc - 1) // 4 + sum(A[:mc]) + dc
	sumb = (yb - 1) * sum(A) + (yb - 1) // 4 + sum(A[:mb]) + db
	print(sumc - sumb + 1)


t = int(input())
for i in range(t):
	n = int(input())
	k = [0] * (n + 1)
	a = [int(x) for x in input().split()]
	a.insert(0, 0)
	for j in range(1, n + 1):
		k[j] = a[j] + k[j - 1]
	(b, c, d) = map(int, input().split())
	(e, f, g) = map(int, input().split())
	z = 0
	f1 = 0
	p = 0
	x = 0
	for j in range(b, e):
		if j % 4 == 0:
			x = x + 1
	if e > b:
		z = z + k[f - 1] + g
	if e - b - 1 > 0:
		f1 = f1 + k[n] * (e - b - 1)
	if b == e:
		p = p + f1 + z + k[f - 1] - k[c] + a[c] - d + 1 + g + x
	else:
		p = p + f1 + z + k[n] - k[c] + a[c] - d + 1 + x
	print(p)


R = lambda : map(int, input().split())
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	B = list(R())
	(by, bm, bd) = R()
	(cy, cm, cd) = R()
	Y = [i for i in B]
	for i in range(1, n):
		Y[i] += Y[i - 1]
	days = Y[n - 1]
	c1 = (by - 1) * days
	if bm > 1:
		c1 += Y[bm - 2]
	c1 += bd
	c2 = (cy - 1) * days
	if cm > 1:
		c2 += Y[cm - 2]
	c2 += cd
	age = c2 - c1 + 1
	for i in range(by, cy):
		if i % 4 == 0:
			age += 1
	print(age)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = [a[0]]
	for i in range(1, n):
		b.append(b[i - 1] + a[i])
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	if d[1] > 1:
		m2 = d[0] * b[n - 1] + b[d[1] - 2] + d[2]
	else:
		m2 = d[0] * b[n - 1] + d[2]
	if c[1] > 1:
		m1 = c[0] * b[n - 1] + b[c[1] - 2] + c[2]
	else:
		m1 = c[0] * b[n - 1] + c[2]
	ans = m2 - m1 + 1 + (d[0] - 1) // 4 - (c[0] - 1) // 4
	print(ans)


from itertools import accumulate
t = int(input())
for x in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	a.insert(0, 0)
	b = []
	b = b + a
	b = list(accumulate(b))
	(yb, mb, db) = list(map(int, input().split()))
	(yc, mc, dc) = list(map(int, input().split()))
	days = 0
	if yb == yc:
		if mc == mb:
			days += dc - db + 1
		else:
			days += a[mb] - db + 1
			for i in range(mb + 1, mc):
				days += a[i]
			days += dc
	else:
		days += a[mb] - db + 1
		for i in range(mb + 1, n + 1):
			days += a[i]
		for i in range(1, mc):
			days += a[i]
		if yb % 4 == 0:
			days += 1
		for i in range(yb + 1, yc):
			if i % 4 == 0:
				days += 1
			days += sum(a)
		days += dc
	print(days)


t = int(input())
for case in range(t):
	months = int(input())
	age = 0
	a = list(map(int, input().split()))
	days = sum(a)
	birth = list(map(int, input().split()))
	current = list(map(int, input().split()))
	(leap, lc) = (False, 0)
	if birth[0] == current[0]:
		if birth[1] == current[1]:
			age += current[2] - birth[2] + 1
		else:
			if birth[0] % 4 == 0:
				a[-1] += 1
			for i in range(birth[1], current[1] + 1):
				if i == birth[1]:
					age += a[i - 1] - birth[2] + 1
				elif i == current[1]:
					age += current[2]
				else:
					age += a[i - 1]
	else:
		for i in range(birth[0], current[0] + 1):
			if i % 4 == 0:
				a[-1] += 1
				(leap, lc) = (True, 1)
			if i == birth[0]:
				temp = sum(a[:birth[1] - 1])
				age += days - temp - (birth[2] - 1) + lc
			elif i == current[0]:
				temp = sum(a[current[1]:])
				age += days - temp - (a[current[1] - 1] - current[2]) + lc
			else:
				age += days + lc
			if leap:
				a[-1] -= 1
				(leap, lc) = (False, 0)
	print(age)


T = int(input())
while T:
	add = 0
	a = 0
	ans = 0
	N = int(input())
	arr = []
	arr = [int(x) for x in input().split()]
	for i in range(0, N):
		add = add + arr[i]
	(y, m, d) = input().split()
	(Y, M, D) = input().split()
	y = int(y)
	m = int(m)
	d = int(d)
	Y = int(Y)
	M = int(M)
	D = int(D)
	dy = Y - y - 1
	if dy > 0:
		ans = dy * add
	if Y == y and M == m and (D == d):
		ans = 1
	elif Y == y and M == m:
		ans = D - d + 1
	elif Y == y:
		for i in range(m, M - 1):
			ans = ans + arr[i]
		ans = ans + D
		ans = ans + arr[m - 1] - d + 1
	else:
		ans = ans + D
		for i in range(0, M - 1):
			ans = ans + arr[i]
		for i in range(m, N):
			ans = ans + arr[i]
		ans = ans + arr[m - 1] - d + 1
		for i in range(y, Y):
			if i % 4 == 0:
				a = a + 1
		ans = ans + a
	print(ans)
	T = T - 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(y_b, m_b, d_b) = map(int, input().split())
	(y_c, m_c, d_c) = map(int, input().split())
	daysofyear = sum(a)
	leep = 0
	a.insert(0, 0)
	for i in range(y_b, y_c):
		if i % 4 == 0:
			leep += 1
	startm = min(m_b, m_c)
	endm = max(m_b, m_c)
	daysofmonth = 0
	for i in range(startm, endm):
		daysofmonth += a[i]
	if m_c > m_b:
		age = (y_c - y_b) * daysofyear + leep + daysofmonth + (d_c - d_b) + 1
	else:
		age = (y_c - y_b) * daysofyear + leep - daysofmonth + (d_c - d_b) + 1
	print(age)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(cy, cm, cd) = map(int, input().split())
	(y, m, d) = map(int, input().split())
	base = sum(arr) * (y - 1)
	base += sum(arr[:m - 1])
	base += d
	base += (y - 1) // 4
	chef = sum(arr) * (cy - 1)
	chef += sum(arr[:cm - 1])
	chef += cd
	chef += (cy - 1) // 4
	print(base - chef + 1)


def fun(birth, today):
	if birth[1] < today[1]:
		return True
	elif birth[1] > today[1]:
		return False
	elif birth[2] <= today[2]:
		return True
	else:
		return False
test = int(input())
for akdjfgjsdh in range(test):
	N = int(input())
	days = list(map(int, input().split()))
	birth = list(map(int, input().split()))
	today = list(map(int, input().split()))
	yeardays = sum(days)
	flag = fun(birth, today)
	ans = 0
	if flag:
		if birth[1] == today[1]:
			ans += today[2] - birth[2]
		else:
			for i in range(birth[1], today[1]):
				if i == birth[1]:
					ans = ans + (days[i - 1] - birth[2])
				else:
					ans += days[i - 1]
			ans += today[2]
	else:
		if birth[1] == N:
			ans += days[N - 1] - birth[2]
		else:
			for i in range(birth[1], N + 1):
				if i == birth[1]:
					ans = ans + (days[i - 1] - birth[2])
				else:
					ans += days[i - 1]
		if today[1] == 1:
			ans += today[2]
		else:
			for i in range(1, today[1]):
				ans += days[i - 1]
			ans += today[2]
		if birth[0] % 4 == 0:
			ans += 1
	if flag:
		for i in range(birth[0], today[0]):
			if i % 4 == 0:
				ans += 1
			ans += yeardays
	else:
		for i in range(birth[0] + 1, today[0]):
			if i % 4 == 0:
				ans += 1
			ans += yeardays
	print(ans + 1)