Counting Weekend Days

The contestants probably don’t know how eagerly problem-setters (The people who prepare problems for a programming contest) wait for the weekend to make problems that would terrorize con- testants :-). So before a month begins, some problem-setters try to calculate the number of weekend days in that month and plans accordingly. Can you help them to calculate this? There are seven days in a week namely Sunday (SUN), Mon- day (MON), Tuesday (TUE), Wednesday (WED), Thursday (THU), Friday (FRI) and Saturday (SAT). There are twelve months in a year, January (JAN), February (FEB), March (MAR), April (APR), May (MAY), June (JUN), July (JUL), August (AUG), September (SEP), October (OCT), November (NOV) and December (DEC). These months have 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 and 31 days respectively. In leap years, the month of February has 29 days. In the bracket the three letter code for each month and each day are shown. Unlike many countries of the world Friday (FRI) and Saturday (SAT) are considered weekend days in Bangladesh. Given a month and the name of the first day of that month, you will have to find out the total no of weekend days in that month. Input First line contains an integer T (T ≤ 100) which denotes the number of test cases. The input for each set is given in a single line. This line contains two strings MTH and DAY, here MTH is the three digit code of the month and DAY is the three digit code for the name of the first day of that Month. Output For each line of input produce one line of output. It contains a single integer which denotes the number of weekend days (Fridays and Saturdays) in that month. You must do your calculation assuming that the year is not a leapleap year. Illustration of third sample input: In the third sample input we are asked to count the number of weekend days of a month October whose first day (October 1) is Thursday. The calendar on the left depicts this and it can be seen that there are 10 weekend days (colored red) in this month. Sample Input 3 JAN SUN FEB SUN OCT THU Sample Output 8 8 10