Under construction

Still being built. Things may change

Employees

Time limit2sMemory limit512 MB

Summary
Given n employees with distinct workloads and hall size k, output for each employee the product of two permutation-based scores, modulo 1e9+7.
Level

Hard9 of 10

Topics
Dynamic programming, Combinatorics, Sorting, Math
Solved
No attempts yet

Problem

There are nn employees in the company Yooglex. The ii-th employee has to work tit_i time units per day. These values are different for all employees. Yooglex's work process is unusual: at every moment only one employee can work, and the rest have to wait until that employee is done.

The Yooglex office consists of a hall and a room. No more than kk employees can be in the hall at the same time. Employees form a queue outside the office to enter the hall. Then the following algorithm applies:

  1. While there are fewer than kk employees in the hall and at least one employee in the queue, the front employee of the queue enters the hall.
  2. If the hall is empty, the day is over and the room is locked.
  3. The employees in the hall choose the one among themselves whose workload for the day is minimal.
  4. The chosen employee enters the room, works for their time, and leaves the office for the day.
  5. Go back to step 1.

The Yooglex board wants to evaluate its employees to assign sensible salaries. Two evaluation methods have been proposed.

The first one is simple. For each of the n!n! possible permutations of the employee queue and each employee ii, calculate the time between the moment the first employee in the queue enters the room and the moment employee ii leaves the room. For each employee, sum these times over all n!n! queue permutations. The sums are the final scores.

The second method is even simpler. For the ii-th employee and each queue permutation, count all employees jj such that tj>tit_j > t_i but employee jj finishes the job before employee ii. This count is the score for employee ii.

Choosing between the two methods is pointless, so a third method is proposed: the score of each employee is the product of the scores from the first two methods.

Can you calculate the third method's scores quickly enough?

Input

The first line contains two integers nn and kk: the number of employees and the hall capacity (1≤n≤3001 \le n \le 300, 1≤k≤n1 \le k \le n).

The second line contains nn integers t1,…,tnt_1, \ldots, t_n: the workloads of the employees (1≤ti≤1091 \le t_i \le 10^9). All tit_i are different.

Output

Output nn integers: the evaluation scores of the employees, in the same order as their workloads in the input. Since the scores can be very large, output them modulo 109+710^9 + 7.

Examples2

  1. Example 1

    Input
    3 1
    2 1 3
    
    Expected output
    72 126 0
    
  2. Example 2

    Input
    4 2
    10 30 2 7
    
    Expected output
    0 0 3564 2208