#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define len(a) (int)a.size()
#define all(a) a.begin(), a.end()

const int INF32 = 1 << 30;
const long long INF64 = 1LL << 60;
const double PI = acos(-1);

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

    vll dp(4, vl(3 * N + 2, 0));
    dp[0][0] = 1;

    rep(i, 3) {
        rep(j, i * N + 1) {
            dp[i + 1][j + 1] += dp[i][j];
            dp[i + 1][j + N + 1] -= dp[i][j];
        }
        rep(j, (i + 1) * N) {
            dp[i + 1][j + 1] += dp[i + 1][j];
        }
    }
    int X;
    for (int i = 3; i <= 3 * N; ++i) {
        if (K > dp[3][i]) {
            K -= dp[3][i];
        }
        else {
            X = i;
            break;
        }
    }
    int ia, ja, ka;
    for (int i = 1; i <= N; ++i) {
        int jmin = max(1, X - N - i);
        int jmax = min(N, X - 1 - i);
        if (jmin > jmax) continue;
        if (K <= jmax - jmin + 1) {
            ia = i;
            ja = jmin + K - 1;
            ka = X - ia - ja;
            break;
        }
        else {
            K -= jmax - jmin + 1;
        }
    }

    cout << ia << ' ' << ja << ' ' << ka << endl;
}

#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr ll INF = 1LL << 30;
constexpr ll mod = 100000; //(ll)1e9 + 7;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
inline void init() {
    cin.tie(nullptr); cout.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}

Graph G;

//探索順をdfs1で求める
vector<bool>ok;
vector<int>path;
void dfs1(int v) {
    ok[v] = false;
    path.push_back(v);
    for (auto nv : G[v])if (ok[nv])dfs1(nv);
}

//pathをもとに塗れる色を全探索
vector<int>color;
int dfs(int l = 0) {
    if (l == path.size())return 1;
    int res = 0;

    vector<int>c(3, 0);
    //色を0,1,2で表現
    for (auto v : G[path[l]]) {
        if (color[v] == -1)continue;
        c[color[v]]++;
    }
    rep(i, 0, 3) {
        if (c[i] != 0)continue;
        color[path[l]] = i;
        res += dfs(l + 1);
        color[path[l]] = -1;
    }
    return res;
}

int main() {
    init();

    int N, M; cin >> N >> M;
    G.resize(N);
    ok.resize(N, true);
    color.resize(N, -1);
    rep(i, 0, M) {
        int a, b; cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll ans = 1;
    rep(i, 0, N) {
        if (ok[i]) {
            path.clear();
            rep(j, 0, N)color[i] = -1;
            dfs1(i);
            ans *= dfs();
        }
    }
    cout << ans << "\n";

    return 0;
}