#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;

#define LL long long
#define DB double
#define MAXN 100
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000001
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
    LL x=0,F=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*F;
}

int MOD;
int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(int a,int b){return (1LL*a*b)%MOD;}
int fst_pow(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=mul(res,a);
		a=mul(a,a),b>>=1;
	}return res;
}
inline void upd(int &x,int y){
	x=(x+y)%MOD;
	if(x<0)x+=MOD;
}


int n,k,lim,res,dp[105][1000005];

int main(){
	n=read(),k=read(),MOD=read();
	lim=k*n*(n-1)/2;
	dp[0][0]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<=lim;j++){
			upd(dp[i][j],dp[i-1][j]);
			if(j>=i)upd(dp[i][j],dp[i][j-i]);
		}
		for(int j=lim;j>=i*(k+1);j--){
			upd(dp[i][j],dec(0,dp[i][j-i*(k+1)]));
		}
	}
	for(int i=1;i<=n;i++){
		res=0;
		for(int j=0;j<=lim;j++)
		res=add(res,mul(dp[i-1][j],dp[n-i][j]));
		printf("%d\n",dec(mul(res,k+1),1));
	}
}
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll f(string s) {
  vector<ll> c(10);
  ll res = 0;
  rep(i, 5) c[s[i] - '0']++;
  for (int i = 1; i < 10; ++i) {
    ll t = i;
    while (c[i]--) t *= 10;
    res += t;
  }
  return res;
}

int main() {
  ll k;
  string s, t;
  cin >> k >> s >> t;

  vector<ll> card(10, k);

  rep(i, 4) card[s[i] - '0']--;
  rep(i, 4) card[t[i] - '0']--;
  ll res = 9 * k - 8;
  ll tot = res * (res - 1);
  ll cnt = 0;
  for (int i = 1; i < 10; ++i) {
    for (int j = 1; j < 10; ++j) {
      s[4] = '0' + i;
      t[4] = '0' + j;
      if (f(s) > f(t)) {
        if (i == j)
          cnt += card[i] * (card[i] - 1);
        else
          cnt += card[i] * card[j];
      }
    }
  }

  long double z = (long double)cnt / tot;

  cout << setprecision(15) << z << endl;
  return 0;
}
