Chef will not be able to attend the birthday of his best friend Rock. He promised Rock that this will not be the case on his half birthday. To keep his promise Chef must know Rock’s next half birthday accurately. Being busy, he is assigning this work to you.
Half birthday is the day that occurs exactly between two subsequent birthdays. 
You will be provided with Rock’s birthdate and birth month, you will have to figure out his half birthday.
$Note$: Consider every year to be a leap year and all months are displayed in lowercase English characters.

-----Input:-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. 
- The description of each of the $T$ test cases contains an integer $d$ followed by a string, denoting month $m$.
- Here $d$ denotes day of a month and $m$ denotes the month of a year respectively.

-----Output:-----
For each test case print an integer $d1$ followed by a string, denoting month $m1$, which overall denotes date and month of Rock’s half birthday.

-----Constraints:-----
- $1 \leq T \leq 10^5$
- $1 \leq d , d1 \leq 31$
- $january \leq m , m1 \leq december$

-----Sample Input:-----
3
15 january
31 august
10 october

-----Sample Output:-----
16 july
1 march
10 april

Starter code:

Solutions:
# cook your dish here
d = {'january':31,'february':29,'march':31,
 'april':30,'may':31,'june':30,'july':31,
 'august':31,'september':30,'october':31,
 'november':30,'december':31}
 
#l=[[15,'january'],[31,'august'],[10,'october']]
l2 = list(d.keys())
for _ in range(int(input())):
 l=input().split()
 l[0]=int(l[0])
 a = l[1]
 ind = l2.index(a)
 b = 183 - (d[l[1]] - l[0])
 while b!=0:
  if ind!=11:
   ind+=1
  else:
   ind = 0
  if b<=d[l2[ind]]:
   print(b,l2[ind])
   break
  b-=d[l2[ind]]

from collections import defaultdict
def solve(date,m):

 arr = [31,29,31,30,31,30,31,31,30,31,30,31]
 copied = arr.copy()
 
 d = {
 "january": 0,
 "february": 1,
 "march": 2,
 "april": 3,
 "may": 4,
 "june": 5,
 "july": 6,
 "august":7,
 "september": 8,
 "october": 9,
 "november":10,
 "december": 11
 }

 month = d[m]

 total = 366//2
 i = month
 total += date

 while(total > 0):
  
  while(arr[i]>0 ):
   if(total<= arr[i]):
    return give(total, i,d)
   else:
    total = total - arr[i]
    i = (i+1) %12
    break


def give(day, month, d):
 temp = None 

 for x in d:
  if(d[x] == month):
   temp = x

 print("{} {}".format(day,temp))

t = int(input())
for _ in range(t):
 d,m = map(str, input().split())

 solve(int(d), m)

for t in range(int(input())):
 a=input().split()
 n,month=int(a[0]),a[1]
 if month=="january":
  d=n
 elif month=="february":
  d=n+31
 elif month=="march":
  d=n+60
 elif month=="april":
  d=n+91
 elif month=="may":
  d=n+121
 elif month=="june":
  d=n+152
 elif month=="july":
  d=n+182
 elif month=="august":
  d=n+213
 elif month=="september":
  d=n+244
 elif month=="october":
  d=n+274
 elif month=="november":
  d=n+305
 else:
  m=12
  d=n+335
 d=(d+183)%366
 if d==0:
  d=366
 if d<=31:
  print(d,"january")
 elif d<=60:
  print(d-31,"february")
 elif d<=91:
  print(d-60,"march")
 elif d<=121:
  print(d-91,"april")
 elif d<=152:
  print(d-121,"may")
 elif d<=182:
  print(d-152,"june")
 elif d<=213:
  print(d-182,"july")
 elif d<=244:
  print(d-213,"august")
 elif d<=274:
  print(d-244,"september")
 elif d<=305:
  print(d-274,"october")
 elif d<=335:
  print(d-305,"november")
 else:
  print(d-335,"december")

import datetime

month_names = [
 "january",
 "february",
 "march",
 "april",
 "may",
 "june",
 "july",
 "august",
 "september",
 "october",
 "november",
 "december"
]

def getHalfBirthday(date, month):
 half_year = datetime.timedelta(days=366/2)

 if month < 2:
  bday = datetime.date(2004, month+1, date)
 else:
  bday = datetime.date(2003, month+1, date)
 hbd = bday + half_year

 hbd = str(hbd.day) + " " + month_names[hbd.month-1]
 return hbd

def main():
 t = int(input())
 for _ in range(t):
  date, month = input().split()
  date = int(date)
  month = month_names.index(month)

  answer = getHalfBirthday(date, month)
  print(answer)

main()


dates = {
"january":1,
"february":2,
"march":3,
"april":4,
"may":5,
"june":6,
"july":7,
"august":8,
"september":9,
"october":10,
"november":11,
"december":12
}

months = {
1: ("january",31),
2: ("february",29),
3: ("march",31),
4: ("april",30),
5: ("may",31),
6: ("june",30),
7: ("july",31),
8: ("august",31),
9: ("september",30),
10: ("october",31),
11: ("november",30),
12: ("december",31)
}

for _ in range(int(input())):
 D, M = [n for n in input().split()]
 D = int(D)
 M = M.lower()
 M = dates[M]
 days = 183 - (months[M][1]-D)
 M+=1
 if(M>12):
  M-=12
 D = 0
 while(days>months[M][1]):
  days-=months[M][1]
  M += 1
  if(M>12):
   M-=12
 print(str(days) + " " + str(months[M][0]))


from datetime import date
from dateutil.relativedelta import relativedelta
cal=["january","february","march",
 "april",
 "may",
 "june",
 "july",
 "august",
 "september",
 "october",
 "november",
 "december"]
def fun(i):
 for j in range(12):
  if(cal[j]==i):
   return j+1;
def fun1(i):
 return cal[i-1]
for _ in range(int(input())):
 t,s=input().split()
 t=int(t)
 x=fun(s)
 if(x>=7):
  s= date(2012,x,t) - relativedelta(days=+183)
 else:
  s= date(2012,x,t) + relativedelta(days=+183)
 y=fun1(s.month)
 print(s.day,y)


from datetime import date
li = ['','january', 'february', 'march', 'april', 'may',
 'june', 'july', 'august', 'september', 'october', 'november', 'december']
t = int(input())
for j in range(t):
 a=list(input().split())
 d=int(a[0])
 m=li.index(a[1])
 if m==2 and d==29:
  print('30 august')
 elif m<=2:
  td = date(2020,m,d)
  td1 = date(2021,m,d)
  diff = (td1-td)/2
  ans = td+diff
  ad,am = ans.day,ans.month
  print(ad,li[am])
 else:
  td = date(2019,m,d)
  td1 = date(2020,m,d)
  diff = (td1-td)/2
  ans = td+diff
  ad,am = ans.day,ans.month
  print(ad,li[am])