#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

    map <ll, ll> a;
    map <ll, ll> b;
    vector <ll> cnt(10,0);

    for(ll i=1; i<=9; i++){
        a[i] = 0;
        b[i] = 0;
    }
    rep(i,4){
        ll tmpa = s[i] - '0';
        ll tmpb = t[i] - '0';
        //cout << tmpa << " " << tmpb  <<endl;
        cnt[tmpa]++;
        cnt[tmpb]++;
        a.at(tmpa)++;
        b.at(tmpb)++;
    }
    ll d = 0, n = 0;
    for(ll i=1;i<=9;i++){
        for(ll j=1;j<=9;j++){
            if(i==j){
                if(k - cnt[i] < 2) continue;
            } 
            else{
                if(k - cnt[i] < 1  || k - cnt[j] < 1) continue;
            }

            //cout << "ok ";
            a.at(i)++;
            b.at(j)++;

            ll pointa = 0;
            ll pointb = 0;
            for(ll m=1; m<=9; m++){
                pointa += m * pow(10, a.at(m));
                pointb += m * pow(10, b.at(m));
            }
            //cout <<  pointa << " " <<pointb<< " ";
            ll tmp;
            if(i==j){
                tmp = (k-cnt[i]) * (k - cnt[i] - 1);
            }
            else tmp  = (k-cnt[i]) * (k - cnt[j]);
            //cout <<  i << " " <<j << " "<<  tmp << endl;
            n += tmp;
            if(pointa > pointb) {
                d += tmp;
                //cout <<  "win";
            }
            a.at(i)--;
            b.at(j)--;
        }
    }
    //cout << n << endl;
    //cout << d << endl;
    cout << setprecision(15);
    cout << (long double)d / (long double)n <<endl;
    
}
#include <bits/stdc++.h>
using namespace std;

// binary exponentiation
// O(log e)
template<class T, class U>
T binary_power(T b, U e){
	T res = 1;
	for(; e; e >>= 1, b *= b) if(e & 1) res *= b;
	return res;
}

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int k;
	string s, t;
	cin >> k >> s >> t;
	s.pop_back();
	t.pop_back();
	array<int, 10> cnt{};
	for(auto c: s){
		++ cnt[c - '0'];
	}
	for(auto c: t){
		++ cnt[c - '0'];
	}
	long long res = 0, cur = 1;
	for(auto d = 1; d < 10; ++ d){
		if(++ cnt[d] <= k){
			cur *= k - cnt[d] + 1;
			for(auto e = 1; e < 10; ++ e){
				if(++ cnt[e] <= k){
					cur *= k - cnt[e] + 1;
					array<int, 10> cnt0{}, cnt1{};
					++ cnt0[d];
					for(auto c: s){
						++ cnt0[c - '0'];
					}
					++ cnt1[e];
					for(auto c: t){
						++ cnt1[c - '0'];
					}
					int s0 = 0, s1 = 0;
					for(auto i = 1; i < 10; ++ i){
						s0 += i * binary_power(10, cnt0[i]);
						s1 += i * binary_power(10, cnt1[i]);
					}
					if(s0 > s1){
						res += cur;
					}
					cur /= k - cnt[e] + 1;
				}
				-- cnt[e];
			}
			cur /= k - cnt[d] + 1;
		}
		-- cnt[d];
	}
	cout << fixed << setprecision(15);
	cout << res / (1.0 * (9 * k - 8) * (9 * k - 9)) << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////