#include "redica.h"
#include <vector>
#include <numeric>
#include <iostream>
using namespace std;
int N;
void rec(int i, int k, int SUM, vector<int> &v)
{
    if (i == N)
    {
        submit(v);
        return;
    }
    for (int j = 1; j <= min(k,SUM); ++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 - 3; ++i)
    {
        v.push_back(query());
        // cerr << v[i] << " ";
    }
    SUM -= accumulate(v.begin(), v.end(), 0);
    // cerr << "\n"
    //      << SUM << "\n";
    rec(max(0, n - 3), k, SUM, v);
    submit(v);
}