#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;
using ll=long long;
using ld=long double;
static const ll INF=1000000000000000;
ll K;
ll sum0[10];
ll sum1[10];
ll Sum0[10];
ll Sum1[10];
string S,T;
int main(){
  cin>>K>>S>>T;
  for(ll i=0;i<4;i++){
  ll x=S[i]-'0';sum0[x]++;
  }for(ll i=0;i<4;i++){
  ll x=T[i]-'0';sum1[x]++;
  }ld ans=0;
  for(ll i=1;i<=9;i++)
    for(ll j=1;j<=9;j++){
    for(ll k=0;k<10;k++){
    Sum0[k]=sum0[k];Sum1[k]=sum1[k];
    }Sum0[i]++;Sum1[j]++;ll x0=0;ll x1=0;
      for(ll k=1;k<10;k++){
      x0+=k*pow(10,Sum0[k]);
        x1+=k*pow(10,Sum1[k]);
      }
    if(x1<x0){
      ld X=(9*K-8)*(9*K-9);
    if(i==j){
    ld Y=(K-sum0[i]-sum1[i])*(K-sum0[i]-sum1[i]-1);
      ans+=Y/X;
    
    }else{
    ld Y=(K-sum0[i]-sum1[i])*(K-sum0[j]-sum1[j]);
      ans+=Y/X;
    }
    }
    }cout<<fixed<<setprecision(10)<<ans<<endl;

  return 0;
}