Days of Our Lives
Easy Accuracy: 25.46% Submissions: 1099 Points: 2

Our favourite character, Joey, is facing a problem in remembering days of the week. He needs to practice learning them. He asks for your help to remember them.
He gives you a month with arbitrary number of days, N, and the day with which it starts, K. You need to tell him the number of Mondays, Tuesdays, ..., Sundays in the month.
The value of K will be 1 for Monday, 2 for Tuesday and so on.

Input : 
First line of input contains a single integer T denoting the number of test cases.
The first line of each test case contains 2 space-separated integers N and K.

Output : 
For each test case, print seven space-separated integers denoting the number of Mondays, Tuesdays, ..., Sundays in a new line.

Constraints : 
1 <= T <= 200
1 <= N <= 10^12
1 <= K <= 7

Example : 
Input : 

3
31 1
28 5
8 1
Output : 
5 5 5 4 4 4 4
4 4 4 4 4 4 4
2 1 1 1 1 1 1

Explanation : 
Case 1 : 

Month starts with Monday.
This week has 5 Mondays, 5 Tuesdays, 5 Wednesdays, 4 Thursdays, 4 Fridays, 4 Saturdays and 4 Sundays.

Case 2 : 
Month starts with Friday.
This week has 4 Mondays, 4 Tuesdays, 4 Wednesdays, 4 Thursdays, 4 Fridays, 4 Saturdays and 4 Sundays.

Case 3 : 
Month starts with Monday.
This week has 2 Mondays, 1 Tuesday, 1 Wednesday, 1 Thursday, 1 Friday, 1 Saturday and 1 Sunday.

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.