#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)

int main(){
  ll k; cin >> k;
  string s, t;
  cin >> s >> t;
  vector<ll> card(10, k);
  rep(i, 4){
    ll x = s[i]-'0';
    ll y = t[i]-'0';
    card[x]--;
    card[y]--;
  }
  ll all = k * 9 - 8;
  ll all2 = all * (all-1);
  ll sum = 0;
  rep2(i, 1, 10){
    if (card[i] == 0) continue;
    rep2(k, 1, 10){
      if (card[k] == 0) continue;
      vector<ll> tvec(10, 0), avec(10, 0);
      rep(j, 4){
        ll x = s[j]-'0';
        ll y = t[j]-'0';
        tvec[x]++;
        avec[y]++;
      }
      tvec[i]++;
      avec[k]++;
      ll tp = 0;
      ll ap = 0;
      rep2(j, 1, 10){
        tp += j * pow(10, tvec[j]);
        ap += j * pow(10, avec[j]);
      }
      if (tp > ap){
        if(i==k) sum += card[i] * (card[k]-1);
        else sum += card[i] * card[k];
      }
    }
  }
  long double ans = (long double)sum / all2;
  cout << ans << endl;
  
  return 0;
}
#include <bits/stdc++.h>
using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const ll mod = 1e9+7;
int sum(int a, int b){return (a+b) % mod;}
int sub(int a, int b){return (a + mod - b) % mod;}
int mul(int a, int b){return (1ll * a * b) % mod;}
int power(int a,int b){
	int res = 1;
	while(b){
		if(b&1)res = mul(res,a);
		b >>= 1;
		a = mul(a,a);
	}
	return res;
}

ll get(string str,char c){
	map<int,int> cnt;
	for(auto &x : str)cnt[x]++;
	cnt[c]++;
	ll res = 0;
	for(char act = '1'; act <= '9'; act++){
		ll tmp = act-'0';
		res += tmp*pow(10,cnt[act]);
	}
	return res;
}
int K;
ld asd(char c1,char c2,map<char,int> cnt){
	if(c1 != c2){
		ld tmp1 = ld(K-cnt[c1])/(9*K-8);
		ld tmp2 = ld(K-cnt[c2])/(9*K-8-1);
		return tmp1*tmp2;
	}
	ld tmp1 = ld(K-cnt[c1])/(9*K-8);
	ld tmp2 = ld(K-cnt[c2]-1)/(9*K-8-1);
	return tmp1*tmp2;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> K;
	string s1,s2; cin >> s1 >> s2;
	map<char,int> cnt;
	for(auto &x : s1)cnt[x]++;
	for(auto &x : s2)cnt[x]++;
	ld res = 0;
	for(char a = '1'; a <= '9'; a++){
		for(char b = '1'; b <= '9'; b++){
			cnt[a]++;
			cnt[b]++;
			if(cnt[a] <= K && cnt[b] <= K){
				ll r1 = get(s1,a);
				ll r2 = get(s2,b);
				
				cnt[a]--;
				cnt[b]--;
				
				if(r1 > r2){
					res += asd(a,b,cnt);
					//cout << a << ' ' << b << '\n';
					//debug(asd(a,b,cnt));
				}
			}else{
				cnt[a]--;
				cnt[b]--;
			}
		}
	}
	//debug(num,den);
	//ld res = num/den;
	cout << fixed << setprecision(15) << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/
