#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
#include <numeric>
#include <chrono>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 998244353;

int dp[3022][6044];

int solve2(int n,int k) {
    if(k > n) return 0;
    if(k == n) return 1;
    if(k == 0) return 0;

    if(dp[n][k] != 0) return dp[n][k];
    return dp[n][k] = (solve2(n-1, k-1) + 0LL + solve2(n, 2*k))%mod;
}

void solve() {
  int n,k;cin>>n>>k;
  cout << solve2(n,k) << endl;
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);
 // cout << fixed << setprecision(15);
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 int t=1;//cin>>t;
 while (t--) {
   solve();
 }

 return 0;
}


#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = ((n) - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

template <typename T>
void print(vector<T>& x) {
    int N = x.size();
    REP(i, N) {
        if (i > 0) cout << " ";
        cout << x[i];
    }
    cout << "\n";
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n, m; cin >> n >> m;

    vector<vector<Pll>> xyz(n + 1);
    REP(i, m) {
        ll _x, _y, _z;
        cin >> _x >> _y >> _z;
        xyz[_x].eb(make_pair(_y, _z));
    }

    vector<ll> dp(1LL << n, 0);
    dp[0] = 1;

    REP(i, n) {
        REVREP(j, 1LL << n) {
            if (bcnt(j) != i || dp[j] == 0) continue;

            REP(k, n) {
                if (j >> k & 1) continue;
                ll sn = j | (1LL << k);
                bool f = true;
                for (auto [y, z]: xyz[i + 1]) {
                    ll mask = (1LL << y) - 1;
                    if (bcnt(sn & mask) > z) {
                        f = false;
                        break;
                    }
                }

                if (f) dp[sn] += dp[j];
            }
        }
    }

    print(dp[(1LL << n) - 1]);
}
