#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> Pair;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}

int dp[101][1001001], sum[101][101][10101];

void Main(){
    int N,K,M; cin >> N >> K >> M;
    VI s(N,0); REP(i,N) s[i] = s[max(0,i-1)] + (i+1)*K;
    dp[0][0] = 1; REP(i,N*N) sum[0][0][i+1] = 1;
    REP(i,N){
        REP(j,s[i]+1){
            int mod = j%(i+1), div = j/(i+1);
            (dp[i+1][j] += sum[i][mod][div+1] - sum[i][mod][max(0,div-K)]) %= M;
            if(dp[i+1][j] < 0) dp[i+1][j] += M;
            mod = j%(i+2); div = j/(i+2);
            sum[i+1][mod][div+1] += dp[i+1][j];
            if(sum[i+1][mod][div+1]>=M) sum[i+1][mod][div+1] -= M;
        }
        REP(j,i+2)REP(k,N*N){
            sum[i+1][j][k+1] += sum[i+1][j][k];
            if(sum[i+1][j][k+1]>=M) sum[i+1][j][k+1] -= M;
        }
    }

    FOR(x,1,N+1){
        ll ans = 0;
        REP(j,N*N*K+1){
            (ans += 1LL*dp[N-x][j]*dp[x-1][j]%M*(K+1)) %= M;
        }
        ans--;
        if(ans<0) ans += M;
        cout << ans << en;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    while(t--) Main();
    return 0;
}
/*
             author:ryo3ihara
            　　　　　　　”継続は力なり、雨だれ石を穿つ”
            　　　　　　　　　　”slow but steady wins the race”
*/

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

//#include<atcoder/all>
//using namespace atcoder;

/* 
// 多倍長テンプレ
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/

using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pii = pair<int, int>;
using pld = pair<ll, ld>;
using ppiii =  pair<pii, int>;
using ppiill = pair<pii, ll>;
using ppllll = pair<pll, ll>;
using pplii = pair<pli, int>;
using mii = map<int, int>;
using dll = deque<ll>;
using qll = queue<ll>;
using pqll = priority_queue<ll>;
using pqrll = priority_queue<ll, vector<ll>, greater<ll>>;
using vint = vector<int>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvint = vector<vector<int>>;
using vvpll = vector<vector<pll>>;

//マクロ
//forループ
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000; //10^12:∞
const ll MAXR = 100000; //10^5:配列の最大のrange

//最大化問題最小化問題
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//高速冪乗化　modの時は一部入れ替える
ll power(ll x, ll y) {
    if(y == 1) {
        return x;
    }
    ll ans;
    if(y % 2 == 1) {
        ll r = power(x,(y-1)/2);
        //ans = r * r % MOD;
        //ans = ans * x % MOD;
        ans = x * r * r;
    }
    else {
        ll r = power(x,y/2);
        //ans = r * r % MOD;
        ans = r * r;
    }
    return ans;
}
/*
Bint powerb(Bint x, Bint y) {
    if(y == 1) {
        return x;
    }
    Bint ans;
    if(y % 2 == 1) {
        Bint r = powerb(x,(y-1)/2);
        //ans = r * r % MOD;
        //ans = ans * x % MOD;
        ans = x * r * r;
    }
    else {
        Bint r = powerb(x,y/2);
        //ans = r * r % MOD;
        ans = r * r;
    }
    return ans;
}
*/

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N,M;
    cin >> N >> M;

    vll H(N),W(M);
    REP(i,N) cin >> H[i];
    REP(i,M) cin >> W[i];

    sort(ALL(H));
    sort(ALL(W));

    vll left((N+1)/2);
    vll right((N+1)/2);

    for(int i =0;i+1<N;i+=2){
        left[i/2+1] = left[i/2] + H[i+1] - H[i];
    }
    for(int i =N-2;i>0;i-=2){
        right[i/2] = right[i/2+1] + H[i+1]-H[i];
    }

    vll dist(N);
    ll ans = INF;
    REP(i,M){
        ll x = lower_bound(H.begin(),H.end(),W[i])-H.begin();
        if(x & 1) x ^= 1;
        chmin(ans,left[x/2] + right[x/2] + abs(H[x] - W[i]));
    }

    //本文

    //出力
    cout << ans << endl;
    //cout << fixed << setprecision(10) << ans << endl;
  return 0;
}