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

ll score(string s){
	vector<ll> cnt(10);
	iota(cnt.begin(), cnt.end(), 0);
	for(char c : s) cnt[c-'0'] *= 10;

	return accumulate(cnt.begin(), cnt.end(), 0);
}

int main(){
	ll k;
	string s,t;
	cin >> k >> s >> t;
	vector<ll> cnt(10,k);
	for(char c : s+t) cnt[c-'0']--;
	ll win = 0;
	for(ll x=1; x<=9; x++){
		for(ll y=1; y<=9; y++){
			s.back() = '0'+x;
			t.back() = '0'+y;
			if(score(s)<=score(t)) continue;
			win += cnt[x]*(cnt[y]-(x==y));
		}
	}

	const ll rem = 9*k-8;
	cout << double(win)/rem/(rem-1) << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll mod = 1000000007;
const double pi = 3.14159265358979;
const ll INF = 1e18;

int main() {
    ll k; cin >> k;
    ll cards = k * 9 - 8;
    string s, t; cin >> s >> t;
    map<char, ll> mps, mpt;
    rep(i, 4) {
        mps[s[i]]++;
        mpt[t[i]]++;
    }
    double ans = 0;
    for (int i = 1; i < 10; i++) {
        if (mps[i + '0'] + mpt[i + '0'] < k) {
            int sprob = k - mps[i + '0'] - mpt[i + '0'];
            mps[i + '0']++;
            ll spoint = 0;
            for (int j = 1; j < 10; j++) {
                spoint += j * pow(10, mps[j + '0']);
            }
            for (int j = 1; j < 10; j++) {
                if (mps[j + '0'] + mpt[j + '0'] < k) {
                    int tprob = k - mps[j + '0'] - mpt[j + '0'];
                    mpt[j + '0']++;
                    ll tpoint = 0;
                    for (int k = 1; k < 10; k++) {
                        tpoint += k * pow(10, mpt[k + '0']);
                    }
                    if (spoint > tpoint) {
                        ans += (double)sprob * tprob / (cards * (cards - 1));
                    }
                    mpt[j + '0']--;
                }
            }
            mps[i + '0']--;
        }
    }
    printf("%.16lf\n", ans);
    return 0;
}