#include<stdio.h>
#include<string.h>
#include<map>
#include<string>
#include<iostream>
#define weeks 5*8+2*4
usingnamespace std;
map<string,int>list;
map<int, string>list1;
int main()
{
list["Monday"]=1;
list["Tuesday"]=2;
list["Wednesday"]=3;
list["Thursday"]=4;
list["Friday"]=5;
list["Saturday"]=6;
list["Sunday"]=7;
list1[1]="Monday";
list1[2]="Tuesday";
list1[3]="Wednesday";
list1[4]="Thursday";
list1[5]="Friday";
list1[6]="Saturday";
list1[7]="Sunday";
char str[1000];
int length;
double speed;
while(~scanf("%s%d%lf", str,&length,&speed))
{
string tp = str;
double tep = length/speed;
int weekday =0, weekend =0;
if(list[tp]<=5) weekday =(5-list[tp]+1)*8+2*4;
else weekday =(7-list[tp]+1)*4;
if(tep > weekday+weekend)
{
tep-=weekday+weekend;
tep =((tep/weeks)-int(tep)/weeks);
tep *= weeks;
tep =int(tep);
cout << list1[tep]<< endl;
}
else
{
if(weekend ==0)
cout << list1[list[tp]-int(weekday/]
}
}
return0;
}
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<queue>
usingnamespace std;
int s[11000];
int top;
int main()
{
int t,n,m;
scanf("%d",&t);
while(t--)
{
top=1;
s[top]=1;
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++)
{
char tmp[10];
scanf("%s",tmp);
if(strcmp(tmp,"PRE")==0)
{
top--;
if(top==0)
{
s[++top]=1;
printf("%d ",s[top]);
}
else
{
printf("%d ",s[top]);
}
}
else
{
if(strcmp(tmp,"NEXT")==0)
{
if(s[top]==n)// shi zuihou
printf("%d ",n);
else
{
int tt=s[top];
printf("%d ",s[top]+1);
s[++top]= tt+1;
}
}
else
{
int key;
scanf("%d",&key);
if(key!=s[top])
s[++top]=key;
printf("%d ",key);
}
}
}
}
return0;
}