#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip> 
#include <stdio.h>
//end of libraries
#define lnf 3999999999999999999
#define inf 999999999
#define PI 3.14159265359
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define rsz(a,n) a.resize(n)
#define pii pair <int,int>
#define rep(i,n) for(int i = 0 ; i < n ; i++) 
#define drep(i,n) for(int i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(int i = x ; i < n ; i++)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

const int max_n = 300000;

using namespace std;
int n;

ll d[20] , f[20] , cnt[20];

bool game(vector <int> a,vector<int> b){
	crep(i,1,10) {d[i]=0;f[i]=0;}

	rep(i,sz(a)) {
		d[a[i]]++;
	}
	rep(i,sz(b)){
		f[b[i]]++;
	}

	int c1=0,c2=0;
	
	crep(i,1,10) {
		c1 += pow(10,d[i]) * i;
		c2 += pow(10,f[i]) * i;
	}

	if(c1>c2) return 1;
	return 0;

}

vector <int> a , b;


void read(){
	string s1,s2;
	cin >> s1 >> s2;
	rep(i,sz(s1)-1) {
		a.pb(s1[i]-'0');
	}
	rep(i,sz(s2)-1){
		b.pb(s2[i]-'0');
	}
}

int main(){
fcin;
	cin >> n;
	read();
	
	crep(x,1,10) {
		int d=0;
		rep(i,sz(a)) if(a[i]==x)d++;
		rep(i,sz(b)) if(b[i]==x)d++;

		cnt[x]=(n-d);

	}
	
	ll e=0,t=0;
	
	crep(x,1,10) {
		crep(y,1,10) {
			if(x==y and cnt[x] < 2) continue;
			a.pb(x);b.pb(y);
			bool g = game(a,b);
			a.pop_back();b.pop_back();
			if(g==1) {
				e+=(cnt[x]*(cnt[y]-(x==y)));
			}
			t+= (cnt[x]*(cnt[y]-(x==y)));
		}
	}
	
	long double e1 = e;
	long double t1 = t;
	cout << fixed<<setprecision(11);
	cout << e1/t1 << "\n";

/*
*/

    return 0;   
}

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

#define int long long

int c1[10], c2[10], cnt[10];
long double fav, tot;

    int qpow(int x, int e){
        if(!e) return 1;
        if(e&1) return qpow(x,e-1)*x;
        return qpow(x*x,e>>1);
    }

main(){

    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cout.setf(ios::fixed); cout.precision(5);
    
    int k;
    cin >> k;
    string s, t;
    cin >> s >> t;

    for(int i = 0; i < s.size()-1; ++i){
        c1[s[i]-'0']++;
        cnt[s[i]-'0']++;
    }
    for(int i = 0; i < t.size()-1; ++i){
        c2[t[i]-'0']++;
        cnt[t[i]-'0']++;
    }

    for(int i = 1; i <= 9; ++i){
        int x = k-cnt[i];
        if(x <= 0) continue;
        for(int j = 1; j <= 9; ++j){
            int y = k-cnt[j]-(i==j);
            if(y <= 0) continue;
            tot += x*y;
            c1[i]++; c2[j]++;
            int sum1 = 0, sum2 = 0;
            for(int k = 1; k <= 9; ++k)
                sum1 = sum1 + k*qpow(10,c1[k]);
            for(int k = 1; k <= 9; ++k)
                sum2 = sum2 + k*qpow(10,c2[k]);
            
            if(sum1 > sum2) fav += x*y;
            c1[i]--; c2[j]--;
        }
    }

    cout << fav/tot;

}