//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
// #define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n) inp(k) inp(mod)
	vector<int> posl={1}, posr={1};
	
	// TODO
	for(int i=1;i<=n;i++)
	{
		vector<int> tposr(posr.size()+i*k), rem(i);
		fo(j,posr.size()+i*k)
		{
			if(j<posr.size())
			{
				rem[j%i]+=posr[j];
				rem[j%i]%=mod;
			}
			tposr[j]=rem[j%i];
			if(j-i*k>=0)
			{
				rem[j%i]-=posr[j-i*k];
				rem[j%i]%=mod;
			}
		
		}
		swap(posr,tposr);
		// cout<<posr<<endl;
	}
	
	vector<int> fans(n/2+n%2);
	for(int i=1;i<=n/2+n%2;i++)
	{
		int x=n-i+1;
		vector<int> rem(x);
		fo(j,posr.size())
		{
			posr[j]=posr[j]-rem[j%x];
			posr[j]%=mod;
			rem[j%x]+=posr[j];
			rem[j%x]%=mod;
			if(j-x*k>=0)
				rem[j%x]-=posr[j-x*k];
			rem[j%x]%=mod;
		}
		
		// cerr<<posl<<'\n';
		// cout<<posr<<"\n\n";
		
		int ans=0;
		fo(j,min(posr.size(),posl.size()))
			ans=(ans+((int)posl[j]*posr[j])%mod)%mod;
		
		vector<int> tposl(posl.size()+i*k);
		rem.clear();
		rem.resize(i);
		fo(j,posl.size()+i*k)
		{
			if(j<posl.size())
			{
				rem[j%i]+=posl[j];
				rem[j%i]%=mod;
			}
			tposl[j]=rem[j%i];
			if(j-i*k>=0)
			{
				rem[j%i]-=posl[j-i*k];
				rem[j%i]%=mod;
			}
		}
		swap(posl,tposl);
		
		
		int ftans=((ans*(k+1))%mod-1)%mod;
		if(ftans<0)
			ftans+=mod;
		fans[i-1]=ftans;
	}
	int ind=n/2-1;
	while(ind>=0)
	{
		fans.push_back(fans[ind]);
		ind--;
	}
	// cout<<fans.size()<<endl;
	assert(fans.size()==n);
	for(int i:fans)
		cout<<i<<'\n';
	printclock;
}
//Bismillahir Rahmanir Raheem
#ifdef ONLINE_JUDGE
    #include<bits/stdc++.h>
#endif
#include<iostream>
#include<numeric>
#include<tuple>
#include<iomanip>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<math.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<string>
#include<sstream>
#include<string.h>
#include<deque>
#include<set>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define clr(cnt, x) memset((cnt), (x), sizeof(cnt))
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int,int> > vii;
typedef pair<int, int> pii;
typedef vector<bool> vbl;
typedef vector<pair<ll,ll> > vll;
typedef pair<ll, ll> pll;
#define PQ priority_queue
#define ff first
#define ss second
#define MP make_pair
#define MT make_tuple
#define mxN (int)2e5 + 2
#define sz(n) (int)(n).size()
#define fasterIO ios::sync_with_stdio(0); cin.tie(0);
#define forc(cn) for(auto &x : (cn))
#define findc(cn, abc) ((cn).find(abc) != (cn).end())

#define PI 2*acos(0)
#define forc(cn) for(auto &x : (cn))
#define MAX 200010
const ll inf = INT_MAX;
const int mod = 1e9 + 7;
struct V {
    ll a, b;
};
bool cmp(const V x, const V y) {
    if(2 * x.a + x.b == 2 * y.a + y.b) 
        return x.a < y.a;
    return 2 * x.a + x.b < 2 * y.a + y.b;
}
void solve()
{
    int n;
    cin >> n;
    vector<V> a(n);
    forc(a) cin >> x.a >> x.b;
    sort(all(a), cmp);
    reverse(all(a));
    ll sa = 0, sb = 0, ans = 0;
    forc(a) sa += x.a;
    forc(a) {
        sb += x.a + x.b;
        sa -= x.a;
        ans++;
        if(sb > sa) break;
    }
    cout << ans << endl;

}
int main()
{
    fasterIO
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r+", stdin);
        freopen("output.o", "w+", stdout);
    #endif
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}
