t=int(input())
for i in range(t):
s,e,l,r=input().split()
l=int(l)
r=int(r)
if s=="monday":
start=1
if e=="monday":
end=1
if s=="tuesday":
start=2
if e=="tuesday":
end=2
if s=="wednesday" :
start=3
if e=="wednesday":

end=3
if s=="thursday":
start=4
if e=="thursday":

end=4
if s=="friday":
start=5
if e=="friday":
end=5
if s=="saturday" :
start=6
if e=="saturday":

end=6
if s=="sunday":
start=7
if e=="sunday":
end=7
diff=abs(start-end)+1
if (diff in list(range(l,r+1))) and (diff+7 not in list(range(l,r+1))):
print(diff)
elif (diff in list(range(l,r+1))) and (diff+7 in list(range(l,r+1))):
print("many")
else:
print("impossible")

asked
**19 Dec '18, 23:33**

0★potterhead123

1

accept rate:
0%