#include<bits/stdc++.h>

using namespace std;

int K;
char S[233],T[233];
int a[233],b[233];
double Ans = 0.0;

int Ten[10] = {1,10,100,1000,10000,100000};

int CountS(int x)
{
	int Sum = 0;
	a[x]++;
	for(int i = 1;i<=9;i++)
		Sum += Ten[a[i]]*i;
	a[x] --;
	return Sum;
}
int CountT(int x)
{
	int Sum = 0;
	b[x]++;
	for(int i = 1;i<=9;i++)
		Sum += Ten[b[i]]*i;
	b[x] --;
	return Sum;
}

int main()
{
	scanf("%d%s%s",&K,S,T);
	for(int i=0;i<4;i++)
	{
		a[S[i]-'0'] ++;
		b[T[i]-'0'] ++;
	}
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
		{
			if(a[i] + b[i] == K) break;
			if(CountS(i) > CountT(j))
			{
				Ans += 1.0 * (K - a[i] - b[i]) / (K * 9 - 8) * 1.0 * (K - a[j] - b[j] - (i==j?1:0)) / (K * 9 - 9);
			}
		}
	printf("%.10lf",Ans);
	return 0;
}
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
typedef pair<int,int> Pai;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  int k;
  string s, t;
  cin >> k >> s >> t;
  map<int, int> mp;
  for (int i = 1; i <= 9; i++) mp[i] = k;
  rep(i, 4) {
    mp[s[i] - '0']--;
    mp[t[i] - '0']--;
  }

  vector<Pai> couple;
  for (int i = 1; i <= 9; i++) { // takahashi card
    mp[i]--;
    if (mp[i] < 0) {
      mp[i]++;
      continue;
    }

    vector<int> v(10);
    rep (ti, 4) v[s[ti] - '0']++;
    v[i]++;
    ll tScore = 0;
    rep (ti, 10) tScore += ti * pow(10, v[ti]);

    for (int j = 1; j <= 9; j++) { // aoki card
      mp[j]--;
      if (mp[j] < 0) {
        mp[j]++;
        continue;
      }

      vector<int> v(10);
      rep (ti, 4) v[t[ti] - '0']++;
      v[j]++;
      ll aScore = 0;
      rep (ti, 10) aScore += ti * pow(10, v[ti]);

      if (tScore > aScore) {
        couple.push_back(make_pair(i, j));
      }
      mp[j]++;
    }

    mp[i]++;
  }
  // rep (i, couple.size()) {
  //   cout << couple[i].first << " / " << couple[i].second << endl;
  // }
  // return 0;

  double ans = 0;
  ll total = 9 * k - 8;
  rep (i, couple.size()) {
    double one = mp[couple[i].first];
    mp[couple[i].first]--;
    ans += (one * mp[couple[i].second]);
    mp[couple[i].first]++;
  }
  ans = ans / (total * (total - 1));
  printf("%.10f\n", ans);
  return 0;
}