#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
typedef long long ll;
/*
#define REPE(i,a) for(i=(a). begin();i!=(a). end();++i)
#define PERE(i,a) for(i=(a).rbegin();i!=(a).rend();--i)
template<class IT>inline void cmx(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmn(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline bool bmx(IT &a,IT b){if(a<b){a=b;return true;}else return false;}
template<class IT>inline bool bmn(IT &a,IT b){if(b<a){a=b;return true;}else return false;}*/
const int N=105,Z=(N*N*N)>>1,B=Z<<1;

/*
inline void ac(){
	int n,i;
	scanf("%d",&n);
	rep(i,1,n);
}*/
int m,D[B+1];
inline void add(int &a){if(a>=m)a-=m;}
inline void sub(int &a){if(a< 0)a+=m;}
inline void A(int a,int k){
	k*=a;
	int i;
	rep(i,a,B)add(D[i]+=D[i-a]);
	per(i,B,k)sub(D[i]-=D[i-k]);
}
inline void S(int a,int k){
	k*=a;
	int i;
	rep(i,k,B)add(D[i]+=D[i-k]);
	per(i,B,a)sub(D[i]-=D[i-a]);
}
inline void M(int a,int k){
	k*=a;
	int i;
	per(i,B-a,0)add(D[i]+=D[i+a]);
	rep(i,0,B-k)sub(D[i]-=D[i+k]);
}
inline int s1(int x){return (x?x:m)-1;}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	
	int n,k,i,s;
	scanf("%d%d%d",&n,&k,&m);
	D[Z]=++k;
	REP(i,1,n)A(i,k);
	printf("%d",s1(D[Z]));
	REP(i,1,n){
		S(n-i,k);
		M(  i,k);
		printf("\n%d",s1(D[Z]));
	}
	return 0;
}
///====================== TEMPLATE STARTS HERE =====================///
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define pb push_back
#define MP make_pair
#define ff first
#define ss second
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define POPCOUNT __builtin_popcountll
#define Set(N,p) ((N)|((1LL)<<(p)))
#define Reset(N,p) ((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)

#define LL long long
#define LLU long long unsigned int
typedef pair < int, int > pii;
typedef pair < LL, LL > pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pll> vll;

#ifdef s_da_sailor
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif // s_da_sailor

inline LL gcd ( LL a, LL b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}

LL ext_gcd ( LL A, LL B, LL *X, LL *Y ){
    LL x2, y2, x1, y1, x, y, r2, r1, q, r;
    x2 = 1; y2 = 0;
    x1 = 0; y1 = 1;
    for (r2 = A, r1 = B; r1 != 0; r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y ) {
        q = r2 / r1;
        r = r2 % r1;
        x = x2 - (q * x1);
        y = y2 - (q * y1);
    }
    *X = x2; *Y = y2;
    return r2;
}

inline LL modInv ( LL a, LL m ) {
    LL x, y;
    ext_gcd( a, m, &x, &y );
    x %= m;
    if ( x < 0 ) x += m;
    return x;
}

inline LL bigmod ( LL a, LL p, LL m ) {
    LL res = 1 % m, x = a % m;
    while ( p ) {
        if ( p & 1 ) res = ( res * x ) % m;
        x = ( x * x ) % m; p >>= 1; /// For bigmod2 multiply here using mulmod
    }
    return res;
}


//int knightDir[8][2] = { {-2,1},{-1,2},{1,2},{2,1},{2,-1},{-1,-2},{1,-2},{-2,-1} };
//int dir4[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
//int dir8[8][2] = {{-1,0},{0,1},{1,0},{0,-1},{-1,-1},{1,1},{1,-1},{-1,1}};
const LL inf = 2147383647;
const LL mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-11;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); /// For generating random numbers

///======================  TEMPLATE ENDS HERE  =====================///

void solve() {
    LL sx, sy, dx, dy;
    cin >> sx >> sy >> dx >> dy;

    if(sx==dx && sy==dy) {
        cout << "0\n";
    }
    else if(sx+sy==dx+dy || sx-sy==dx-dy || abs(sx-dx)+abs(sy-dy)<=3) {
        cout << "1\n";
    }
    else if((sx+sy)%2 == (dx+dy)%2) {
        cout << "2\n";
    }
    else if(abs(sx-dx)<=5 && abs(sy-dy)<=5) {
        cout << "2\n";
    }
    else if((sx==dx && abs(dy-sy)==6) || (sy==dy && abs(dx-sx)==6)) {
        cout << "2\n";
    }
    else if(abs((dx+dy)-(sx+sy))<=4 || abs((dx-dy)-(sx-sy))<=4) {
        cout << "2\n";
    }
    else {
        cout << "3\n";
    }
}

int main () {
    #ifdef s_da_sailor
    freopen ( "input.txt", "r", stdin );
    //freopen ( "output.txt", "w", stdout );
    #endif // s_da_sailor

    fast_cin;

    solve();

    return 0;
}

