#include "redica.h"
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 307, MAXS = MAXN*MAXN, THR = 296, THR1 = 1e4;
int n, k, s, dp[MAXN][MAXS], a, idx, pos, sum;
vector<int> v;

void brute()
{
    if(pos == n+1)
    {
        if(sum == s) submit(v);
        return;
    }
    for(int i = min(s-sum, k); i >= 1; i--)
    {
        idx++;
        v[idx] = i;
        pos++;
        sum += i;
        brute();
        pos--;
        sum -= i;
        idx--;
    }
    return;
}

void solve(int N, int K, int S)
{
    n = N;
    k = K;
    s = S;
    for(int j = max(0, s-k); j <= s-1; j++)
    {
        dp[n][j] = 1;
    }
    for(int i = n-1; i >= 1; i--)
    {
        for(int j = 0; j <= s; j++)
        {
            for(int jj = j+1; jj <= min(s, j+k); jj++)
            {
                dp[i][j] += dp[i+1][jj];
                if(dp[i][j] > THR1) dp[i][j] = THR1+1;
            }
        }
    }
    v.resize(n);
    idx = -1;
    //if(n == 300 && s == 300*300) assert(false);
    for(int i = 0; i <= n; i++)
    {
        if((dp[i+1][sum] <= THR1 || i >= THR) || i == n)
        {
            pos = i+1;
            brute();
            break;
        }
        a = query();
        sum += a;
        v[i] = a;
        idx = i;
    }
    return;
}
