#include <iostream>
#include <vector>
#include <set>
#include <map>

template <class E> struct FenwickTree {
    int _n;
    std::vector<E> data;

    FenwickTree(int n) : _n(n), data(n) { }

    void add(int p, E x) {
        ++p;
        while (p <= _n) {
            data[p - 1] += x;
            p += p & -p;
        }
    }
    E sum(int r) const {
        E s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
    E sum(int l, int r) const {
        return sum(r) - sum(l);
    }
};

long long proc(
    std::vector<int>             &cur,
    int                          x,
    int                          y,
    FenwickTree<int>             &ftcnt0,
    FenwickTree<long long>       &ftsum0,
    const FenwickTree<int>       &ftcnt1,
    const FenwickTree<long long> &ftsum1,
    const std::vector<int>       &arr)
{
    int v = cur[x];
    long long dem = (long long)ftcnt1.sum(0, v) * arr[v];
    long long cre = (long long)ftcnt1.sum(0, y) * arr[y];
    long long adj = (long long)ftsum1.sum(y, v);

    ftsum0.add(v, -arr[v]);
    ftcnt0.add(v, -1);
    cur[x] = y;
    ftsum0.add(y, arr[y]);
    ftcnt0.add(y, 1);

    return cre + adj - dem;
}

int main(int argc, char **argv)
{
    int n, m, q;
    std::cin >> n >> m >> q;
    std::set<int> s = { 0 };
    std::vector<int> ta(q), xa(q), ya(q);

    for (int i = 0; i < q; i++) {
        std::cin >> ta[i] >> xa[i] >> ya[i];
        xa[i]--;
        s.insert(ya[i]);
    }
//    std::vector<int> arr(s.begin(), s.end());
    int ll = s.size();
    std::vector<int> arr(ll);
    std::map<int, int> map;
    int ii = 0;
    for (auto &k : s) {
        arr[ii] = k;
        map.emplace(k, ii);
        ++ii;
    }

    FenwickTree<long long> ftsuma(ll);
    FenwickTree<long long> ftsumb(ll);
    FenwickTree<int>       ftcnta(ll);
    FenwickTree<int>       ftcntb(ll);
    std::vector<int> cura(n);
    std::vector<int> curb(m);
    ftcnta.add(0, n);
    ftcntb.add(0, m);
    long long sum = 0;

    for (int i = 0; i < q; i++) {
        int cy = map[ya[i]];
        sum += (ta[i] == 1) ? proc(cura, xa[i], cy, ftcnta, ftsuma, ftcntb, ftsumb, arr)
                            : proc(curb, xa[i], cy, ftcntb, ftsumb, ftcnta, ftsuma, arr); 
        std::cout << sum << std::endl;
    }
    return 0;
}
#include<cstdio>
#include<iostream>
using namespace std;
int n,k;
long long MO,dp[110][180000];
int main()
{
	scanf("%d%d%lld",&n,&k,&MO);
	long long sum;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		sum=((1+min(i,n-i-1))*min(i,n-i-1)/2)*k;
		for(int kk=0;kk<=k;kk++)
			for(int j=kk*i;j<=sum;j++)
				(dp[i][j]+=dp[i-1][j-kk*i])%=MO;
	}
	for(int i=1;i<=n;i++)
	{
		long long ans=0;
		sum=((1+min(i-1,n-i))*min(i-1,n-i)/2)*k;
		for(int j=1;j<=sum;j++)
			(ans+=(dp[i-1][j]*dp[n-i][j]%MO)*(k+1))%=MO;
		printf("%lld\n",(ans+k)%MO);
	}
	return 0;
}