#include<bits/stdc++.h>
using namespace std;
string conv(int n){
if(n==0){
return "0";
}
string ans;
while(n>0){
ans.insert(ans.begin()+0, (n%10)+'0' );
n/=10;
}
return ans;
}
string solve(string s, string e, int l, int r){
vector<string> week={"monday", "tuesday", "wednesday",
"thursday", "friday", "saturday", "sunday"};
int minDays=0;
int startNum;
for(int i=0;i<7;i++){
if(s==week[i]){
startNum=i;
break;
}
}
int i=startNum;
while(true){
if(week[i]==e){
minDays++;
break;
}
minDays++;
i=(i+1)%7;
}
int count=0;
int unique;
for(int j=l;j<=r;j++){
if(count>1){
break;
}
if( j==minDays ){
unique=j;
count++;
}else{
if( (j-minDays)%7 == 0 ){
unique=j;
count++;
}
}
}
string ans;
if(count==1){
ans=conv(unique);
}else if(count>1){
ans="many";
}else{
ans="impossible";
}
return ans;
}
int main(){
// freopen("ip.txt","r",stdin);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
string s,e;
int l,r;
cin>>s>>e>>l>>r;
cout<<solve(s,e,l,r)<<endl;
}
return 0;
}