#include "redica.h"
#include <vector>
#include <numeric>
using namespace std;
int N;
void rec(int i, int k, int SUM, vector<int> &v)
{
    if (SUM < 0)
        return;
    if (i == N)
    {
        submit(v);
        return;
    }
    for (int j = 1; j <= k; ++j)
    {
        v.push_back(j);
        rec(i + 1, k, SUM - j, v);
        v.pop_back();
    }
}

void solve(int n, int k, int SUM)
{
    N = n;
    std::vector<int> v;
    for (int i = 0; i < n - 7; ++i)
        v.push_back(query());
    SUM -= accumulate(v.begin(), v.end(),0);
    rec(0, k, SUM, v);
    submit(v);
}