#include <bits/stdc++.h> using namespace std;
int main() { int H, W, M; cin >> H >> W >> M;
vector<vector<int>> ans(H + 1, vector<int>(W + 1, 0));
vector<vector<int>> comb(H + W + 2, vector<int>(H + W + 2, 0));
// Precompute combinations modulo M using Pascal's identity
comb[0][0] = 1 % M;
for (int n = 1; n <= H + W; ++n) {
comb[n][0] = 1 % M;
for (int k = 1; k <= n; ++k) {
comb[n][k] = (comb[n-1][k-1] + comb[n-1][k]) % M;
}
}
for (int h = 1; h <= H; ++h) {
for (int w = 1; w <= W; ++w) {
ans[h][w] = comb[h + w][h] % M;
}
}
for (int i = 1; i <= H; ++i) {
for (int j = 1; j <= W; ++j) {
cout << ans[i][j];
if (j < W) cout << ";
}
cout << endl;
}
return 0;
}