#include <bits/stdc++.h>          
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll N, K;

ll nC2(ll n) {
    if (n<2) return 0;
    return n * (n-1) / 2;
}

ll nC1(ll n) {
    if (n<1) return 0;
    return n;
}

ll cnt_ijk(ll S) {
    ll res = nC2(S-3+2);
    res -= 3 * nC2(S-N-3+2);
    res += 3 * nC2(S-2*N-3+2);
    res -= nC2(S-3*N-3+2);
    return res;
}

ll cnt_jk(ll S) {
    ll res = nC1(S-2+1);
    res -= 2 * nC1(S-N-2+1);
    res += nC1(S-2*N-2+1);
    return res;
}

int main() {
    cin >> N >> K;

    ll cnt = 0, ijk = 0;
    for (ll i=3; i<=3*N; i++) {
        cnt += cnt_ijk(i);
        if (cnt>=K) {
            cnt -= cnt_ijk(i);
            ijk = i;
            break;
        }
    }

    ll imin = max(1LL,ijk-2*N), imax = min(N,ijk-2);
    ll I = 0, jk = 0;
    for (ll i=imin; i<=imax; i++) {
        cnt += cnt_jk(ijk-i);
        if (cnt>=K) {
            cnt -= cnt_jk(ijk-i);
            I = i;
            jk = ijk - i;
            break;
        }
    }

    ll jmin = max(1LL,jk-N), jmax = min(N,jk-1);
    ll J = 0;
    for (ll j=jmin; j<=jmax; j++) {
        cnt++;
        if (cnt==K) {
            J = j;
            cout << I << " ";
            cout << J << " ";
            cout << jk - J << endl;
            return 0;
        }
    }
}
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int N = 3;

int main(void) {
	int n;
	ll k;
	cin >> n >> k;
	vector<vector<ll>> dp(N + 1, vector<ll>(N * n + 2, 0LL));
	dp[0][0] = 1LL;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= (i * n); j++) {
			dp[i + 1][j + 1] += dp[i][j];
			dp[i + 1][j + 1 + n] -= dp[i][j];
		}
		for (int j = 1; j < (i + 1) * n + 2; j++) {
			dp[i + 1][j] += dp[i + 1][j - 1];
		}
	}
	int sum;
	for (sum = N; sum <= N * n; sum++) {
		if (k <= dp[N][sum]) {
			break;
		}
		k -= dp[N][sum];
	}
	vector<int> ans(N);
	for (int i = 0; i < N - 1; i++) {
		for (int j = 1; j <= n; j++) {
			if (k <= dp[N - i - 1][sum - j]) {
				ans[i] = j;
				sum -= j;
				break;
			}
			k -= dp[N - i - 1][sum - j];
		}
	}
	ans[N - 1] = sum;
	for (int i = 0; i < N; i++) {
		if (i) {
			cout << " ";
		}
		cout << ans[i];
	}
	cout << endl;
	return 0;
}
