#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
//bool vis[1000];
//int x[]={1,-1,0,0};
//int y[]={0,0,1,-1};
//int f=0;
//"'';
int main(){
 ll n,k;
 cin>>n>>k;
ll sum=3*n;
vector<vector<ll> > dp(4,vector<ll>(sum+1,0));
vector<vector<ll> > sm(4,vector<ll>(sum+1,0));
dp[0][0]=1;
for(int i=0;i<=sum;i++){
    sm[0][i]=1;
}
for(int i=1;i<=3;i++){
    for(int j=1;j<=sum;j++){
        int mx=j-1;
        int mn=max(0ll,j-n);
        dp[i][j]=sm[i-1][mx];
        if(mn>0){
            dp[i][j]=dp[i][j]-sm[i-1][mn-1];
        }
       // cout<<i<<-1<<j<<-1<<dp[i][j]<<endl;
        sm[i][j]+=sm[i][j-1]+dp[i][j];
    }
}
int a;
for(int i=1;i<=sum;i++){
    if(sm[3][i]>=k){
            k=k-sm[3][i-1];
        a=i;
        break;
    }
}
//cout<<k<<endl;
//cout<<a<<endl;
for(int i=3;i>=1;i--){
    for(int j=1;j<=n;j++){
        if(a-j>=0&&dp[i-1][a-j]>=k){
            cout<<j<<" ";
            a=a-j;
            break;
        }
        else{
             k=k-dp[i-1][a-j];
        }
    }
}
cout<<endl;
}



#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long N, K; cin >> N >> K; 
	long long A[3000010] = {}; 
	long long S[3000010] = {}; 
	for(long long i = 3; i <= N+2; i++){
		A[i] = (i-1) * (i-2) / 2; S[i] = A[i] + S[i-1];  
	}
	for(long long i = N+3; i <= N*2; i++){
		A[i] = (i-1) * (i-2) / 2 - (i - N - 1) * (i - N - 2) / 2 * 3; 
		S[i] = A[i] + S[i-1]; 
	}
	for(long long i = N*2 + 1; i <= N*3; i++){
		A[i] = A[N*3+3-i]; S[i] = A[i] + S[i-1]; 
	}
	long long sum = lower_bound(S, S+N*3+1, K) - S; 
	long long M = K - S[sum - 1]; 
	long long B[1000010] = {}; 
	long long T[1000010] = {}; 
	for(long long i = 1; i <= N; i++){
		long long rem = sum - i; 
		if(rem <= 1) B[i] = 0; 
		else if(rem <= N+1) B[i] = rem - 1; 
		else if(rem <= N*2) B[i] = N*2+1 - rem; 
		else B[i] = 0; 
		T[i] = B[i] + T[i-1]; 
	}
	long long a = lower_bound(T, T+N+1, M) - T; 
	long long L = M - T[a-1]; 
	for(long long i = 1; i <= N; i++){
		if(sum - a - i >= 1 && sum - a - i <= N) L--;
		if(L == 0){
			cout << a << " " << i << " " << sum - a - i << "\n"; 
			return 0; 
		}
	}
}