#include <bits/stdc++.h>
#include "redica.h"

using namespace std;

int n1, k1, s1;

vector<int> ans;

void f(int FoundS, int steps)
{
    if(steps == 0)
    {
        submit(ans);
        return;
    }
    for(int i = 1; i <= min(k1, FoundS - steps + 1); i++)
    {
        ans.push_back(i);
        f(FoundS - i, steps - 1);
        ans.pop_back();
    }
}

void solve(int N, int K, int S)
{
    int Found_Sum = S;
    n1 = N;
    k1 = K;
    s1 = S;

    int stp = 1;
    int br = k1;
    for(int i = 2; i <= N; i++){
        br *= K;
        if(br > int(5e8))
            break;
        stp++;
    }

    for(int i = 1; i <= N - stp; i++)
    {
        int x = query();
        Found_Sum -= x;
        ans.push_back(x);
    }

    for(int i = 1; i <= min(K, Found_Sum - stp + 1); i++)
    {
        ans.push_back(i);
        f(Found_Sum - i, stp - 1);
        ans.pop_back();
    }

}
