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

int n, k, s;
vector<int> v;
int cs;

void Rec()
{
    if (v.size() == n)
    {
        submit(v);
        return;
    }
    for (int i = 1; i <= k; i++)
    {
        if (cs + i > s)
            break;
        cs += i;
        v.push_back(i);
        Rec();
        cs -= i;
        v.pop_back();
    }
}

void solve(int nn, int kk, int ss)
{
    n = nn;
    k = kk;
    s = ss;
    int op = 7;
    if (k <= 10)
        op = 5;
    if (n <= 7)
        op = 0;
    if (n > 15)
    {
        if (n > 30)
            op = n - 3;
        else
        {
            op = 26;
            if (k < 30)
                op = 25;
            if (k < 15)
                op = 24;
        }
    }
    for (int i = 0; i < min(n, op); i++)
    {
        v.push_back(query());
        cs += v.back();
    }
    Rec();
}