#include <bits/stdc++.h>
using namespace std;
     
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
     
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<pair<long double, int> , null_type,less<pair<long double, int> >, rb_tree_tag,tree_order_statistics_node_update> 
    
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
     
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
     
const int inf = int(1e9);
const ll INF = ll(1e16);
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
 
ll bp(ll a, ll n, ll cm){
  ll r = 1;
  while(n){
    if(n & 1) r = r * a % cm;
    a = a * a % cm;
    n >>= 1;
  }
  return r; 
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
    
    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
} 
void solve(){

  ll n, C;
  cin >> n >> C;
  ll a[n], b[n], c[n];
  vector<pll> v;
  rep(i, n){
    cin >> a[i] >> b[i] >> c[i];
    v.pb({a[i], c[i]});
    v.pb({b[i] + 1, -c[i]});
  }
  sort(all(v));
  ll S = 0;
  ll curSum = 0;
  rep(i, sz(v) - 1){
    curSum += v[i].S;
    ll delta = v[i + 1].F - v[i].F;
    S += min(curSum, C) * delta;
  }
  cout << S;
}

int main()
{
  // freopen("input.txt", "r", stdin)
  // freopen("output.txt", "w", stdout);
    Red;
    int T = 1;
    // cin >> T;
    for(int i = 1; i <= T; ++i){
      solve();
    }
    return 0;

    
}
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define printg(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int get_random() {
    static uniform_int_distribution<int> dist(0, 1e9 + 6);
    return dist(rng);
}
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}


typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

template<class T>
void make_unique(T & v) {
    sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
}
int geti() { int x; cin >> x; return x; }
long long getll() { long long x; cin >> x; return x; }
double getd() { double x; cin >> x; return x; }
// pair<int, int> a(geti(), geti()) does not work
// pair<int, int> a({geti(), geti()}) works, since it uses initializer.

const int MAXN = 3e5 + 100;


void solve(int tt) {
    // cout<<"Case #"<<tt<<": ";

}

int n,m,k;

vi c[101];

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // solve_testcase;

    cin>>n>>k>>m;
    c[1] = vi(k + 1, 1);
    rep(i,2,n+1) {
    	int ub=k*i*(i+1)/2+1;
    	if(i>n+1-i) mini(ub,(int)c[n+1-i].size());
    	c[i] = vi(ub);

    	rep(j,0,c[i-1].size()) {
    		if(c[i-1][j]==0) continue;
    		rep(cc,0,k+1) {
    			if(j+cc*i >= c[i].size()) break;
    			c[i][j+cc*i]+=c[i-1][j];
    			if(c[i][j+cc*i]>=m) c[i][j+cc*i]-=m;
    		}
    	}
    }
    // rep(i,1,n+1) print(i,c[i]);

    vi res(n+1);
    res[1]=k;
    res[n]=k;
    rep(i,2,n) {
    	if(i>n+1-i) break;
    	ll tmp=0;
    	int n1=c[i-1].size();
    	int n2=c[n-i].size();
    	rep(j,0,min(n1,n2)) {
    		tmp=(tmp+(ll)c[i-1][j]*(ll)c[n-i][j]%m)%m;
    	}
    	res[i]=(tmp*(k+1)%m+m-1)%m;
    	res[n+1-i]=res[i];
    }
    rep(i,1,n+1)cout<<res[i]<<endl;


    return 0;
}


















