14010 - Jangan Makan Indomieku   

Description

TA Arithat is feeling upset because all of his k cups of Indomie were eaten during the test. To determine who is responsible, he has summoned n students to the classroom. As each student enters, they must follow a specific rule for knocking on the table:

  1. When the first student arrives, they knock on the table once.
  2. For subsequent students:
    • If the total number of students who have arrived so far is odd, the student must knock the table k times that of the previous student.
    • If the total number of students who have arrived so far is even, the student must knock the table k times more than the previous student.

After all students have knocked, the last student to arrive may knock on the door again using the same rule, and then everyone in the room will take turns knocking in reverse order of their initial entry.

For example, if there are 5 students named Alice, Bob, Charlie, David, and Eve, and k is 2, the knocking sequence would look like this:

(Alice enters, 1 student in total)
Alice: 1

(Bob enters, 2 students in total)

Alice: 1, Bob: 3, Alice: 1

 (Charlie enters, 3 students in total)

Alice: 1, Bob: 2, Charlie: 4, Bob: 2, Alice: 1

(David enters, 4 students in total)

Alice: 1, Bob: 3, Charlie: 5, David: 7, Charlie: 5, Bob: 3, Alice: 1

(Eve enters, 5 students in total)

Alice: 1, Bob: 2, Charlie: 4, David: 8, Eve: 16, David: 8, Charlie: 4, Bob: 2, Alice: 1

As the first student, your task is to keep a record of how many times each student knocked on the table. You do not need to include their names in the record.

Input

All test case contains two positive integer n and k. (1 ≤ n ≤ 32, 1 ≤ k ≤ 10)

Output

The record of how many times every person has knocked in each round. The number of times a student knocks on the table is to be separated by a space. At the end of each round, you must output an endline character '\n'.

It is guaranteed that all numbers are less than 263 - 1

Sample Input  Download

Sample Output  Download

Tags




Discuss