#include <bits/stdc++.h>
typedef long long ll;
const ll max_N = 100;
const ll max_M = 1000000;
ll n, K, mod, dp[max_N + 5][max_M + 5], G[max_M + 5];
ll read() {
	char c = getchar(); ll ans = 0;
	while (c < '0' || c > '9') c = getchar();
	while (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();
	return ans;
}
void Write(ll x) {
	if (x < 10) putchar(x + '0');
	else Write(x / 10), putchar(x % 10 + '0');
}
ll add(ll x, ll y) {return (x += y) >= mod ? x - mod : x;}
ll sub(ll x, ll y) {return (x -= y) < 0 ? x + mod : x;}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll calc(ll id) {
	ll sum = 0;
	for (ll i = 0; i <= max_M; i++)
		sum = (sum + dp[id - 1][i] * dp[n - id][i]) % mod;
	return sum;
}
int main() {
	n = read(), K = read() + 1, mod = read(); dp[0][0] = 1;
	for (ll i = 1; i <= n; i++) {
		for (ll j = 0; j <= max_M; j++) G[j] = 0;
		for (ll j = 0; j <= max_M; j++)
			G[j] = add(dp[i - 1][j], (j >= i ? G[j - i] : 0));
		for (ll j = 0; j <= max_M; j++)
			dp[i][j] = sub(G[j], (j >= i * K ? G[j - i * K] : 0));
	}
	for (ll i = 1; i <= n; i++) Write((calc(i) * K + mod - 1) % mod), putchar('\n');
	return 0;
}

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[1010], B[1010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i] >> B[i];

	int ans = inf;
	rep(a, 0, N) rep(b, 0, N) {
		int cost;
		if (a == b) cost = A[a] + B[b];
		else cost = max(A[a], B[b]);
		chmin(ans, cost);
	}
	cout << ans << endl;
}





