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
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()

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()
