Days of Our Lives
Submissions: 907   Accuracy:

22.66%

  Difficulty: Easy   Marks: 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.

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: goyalanubhav11


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.