1.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
* Angewandte Mathematik, SS11
* Problem: 12019 - Doom's Day Algorithm
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=10&page=show_problem&problem=834
*
* @author Unverzart Michael
* @author Wurth Manuel
* @version 1.0, 22/6/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.140
*/

public class Main {
public static void main(String[] args) throws Exception{
String[] d = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
int doomsday = 1; //2011 Monday
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int t = new Integer(reader.readLine());
for(int i = 1; i<=t; i++){
StringTokenizer st = new StringTokenizer(reader.readLine());
int month = new Integer(st.nextToken());
int day = new Integer(st.nextToken());
int diff = 0;
switch (month) {
case 1: diff=day-3; break;
case 2: diff=day-28; break;
case 3: diff=day-7; break;
case 4: diff=day-4; break;
case 5: diff=day-9; break;
case 6: diff=day-6; break;
case 7: diff=day-11; break;
case 8: diff=day-8; break;
case 9: diff=day-5; break;
case 10: diff=day-10; break;
case 11: diff=day-7; break;
case 12: diff=day-12; break;
default: break;
}
int weekday = doomsday+diff;
if(weekday>6) weekday%=7;
else while(weekday<0) weekday+=7;
System.out.println(d[weekday]);
}
}
}