Doom's Day Algorithm
month=[0,31,28,31,30,31,30,31,31,30,31,30,31]
day=['Friday','Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday']
T=input()
for t in range(int(T)):
a,b=map(int, input().split())
sum=0
for i in range(a):
sum+=month[i]
sum+=b
print(day[sum%7])
Cheapest Base
T=input()
bug=0
for t in range(int(T)):
if t>0:
print()
print('Case '+str(t+1)+':')
arr=[]
if bug==0:
for i in range(4):
arr+=(map(int, input().split()))
TT=input()
else:
arr=bugarr
TT=bugTT
for tt in range(int(TT)):
a=list(map(int, input().split()))
if len(a)>1:
bug=1
bugarr=a[1:36]
bugTT=a[37]
tmp=a[0]
a=[]
a.append(tmp)
a=a[0]
x=a
m=99999999999999
ans=[]
for i in range(2,37):
a=x
count=0
while a>0:
count+=arr[a%i]
a=a//i
if count<m:
ans=[]
ans.append(i)
m=count
elif count==m:
ans.append(i)
print('Cheapest base(s) for number '+str(x)+':',end="")
for i in ans:
print(' '+str(i),end="")
print()