#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <iostream>
#include <iomanip>

constexpr int HeighestDim = 505000;

int n, m, k;
long long int res[101];
int dim_a = 0, dim_b = 0;
int A[HeighestDim + 1], B[HeighestDim];

void mult_a(int v){
    for(int i = dim_a, j = i - v; j >= 0; --i, --j){ A[i] -= A[j]; if(A[i] < 0) A[i] += m; }
}
void div_a(int v){
    for(int i = v, j = 0; i <= dim_a; ++i, ++j){
        A[i] += A[j]; if(A[i] >= m) A[i] -= m;
    }
}

void mult_b(int v){
    dim_b += v;
    for(int i = dim_b, j = i - v; j >= 0; --i, --j){
        B[i] -= B[j]; if(B[i] < 0) B[i] += m;
    }
}
void div_b(int v){
    for(int i = v, j = 0; i <= dim_b; ++i, ++j){
        B[i] += B[j]; if(B[i] >= m) B[i] -= m;
    }
}

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    A[0] = 1; B[0] = 1;
    std::cin >> n >> k >> m; ++k;
    const int hd = (n >> 1) + (n & 1);
    {
        int i, j;
        for(i = 1, j = k; i <= hd; ++i, j += k){ dim_a += j; mult_a(j); div_a(i); }
        for(; i < n; ++i, j += k){ mult_a(j); div_a(i); }
    }
    for(int i = 0, j = n, I = k, J = k * (n - 1); ; I += k, J -= k){
        long long int res_v = 0;
        for(int d = 0; d <= dim_b; ++d) res_v += static_cast<long long int>(A[d]) * B[d] % m;
        if(res_v) res_v = (k * res_v - 1) % m; else res_v = m - 1;
        res[i++] = res_v; res[--j] = res_v;
        if(i > j) break;
        mult_a(j); div_a(J);
        mult_b(I); div_b(i);
    }

    for(int i = 0; i < n; ++i) std::cout << res[i] << '\n';
    return 0;
}
# include <bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
# define rrep(i,r,l) for(int i=(r); i>=l; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
typedef long long lint;
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; }
#define INF ((1LL<<62)-(1LL<<31)) /*オーバーフローしない程度に大きい数*/
#define MOD 1000000007
lint gcd(lint a,lint b){
    if(!b)return a;
    return gcd(b,a%b);
}
 
lint lcm(lint a,lint b){
    return a*b/gcd(a,b);
}

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

void solve() {
    int h,w,n;
    cin >> h >>w >> n;
    vector<int> a(w,h),b(h,w);
    
    rep(i,0,n){
        int x,y;
        cin >> x >> y;x--,y--;
        chmin(a[y],x);
        chmin(b[x],y);
    }
    lint ans=0;
    rep(y,0,b[0]) ans+=a[y];
    rep(x,0,a[0]) ans+=b[x];

    BinaryIndexedTree<int> t(w);
    rep(i,0,b[0]) t.add(i, 1);
    
    vector<vector<int>> ends(h+1);
    rep(y,0,b[0]) ends[a[y]].push_back(y);

    rep(x,0,a[0]){
        for(int y:ends[x]) t.add(y,-1);
        ans-=t.sum(b[x]-1);
    }
    cout << ans << endl;

}

signed main() {

    solve();

    return 0;
}