#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int k;
unordered_map<int, int> s,t, rest;

int winTaka(int taka, int aoki, unordered_map<int, int> s, unordered_map<int, int> t) {
  s[taka]++;
  t[aoki]++;
  int total = 0;
  for (int i=1; i<10; i++) {
    int e = int(pow(10, s[i]))-int(pow(10, t[i]));
    total+= i*e;
  }
  return total>0.0;
}

int main() {
  INCANT;
  cin >> k;
  char c;
  rep(i, 5) {
    cin >> c;
    if (i==4) continue;
    s[c-'0']++;
  }
  rep(i, 5) {
    cin >> c;
    if (i==4) continue;
    t[c-'0']++;
  }
  
  rep(i, 9) {
    int num = i+1;
    rest[num] = k-s[num]-t[num];
  }
  double denominator = 9*k-8;
  double coeffient;
  double ans = 0.0;
  for(int i=1; i<10; i++) {
    for (int j=1; j<10; j++) {
      if (i==j && rest[i]-2<0) continue;
      if (rest[i]-1<0) continue;
      if (rest[j]-1<0) continue;
      if (i==j) {
        coeffient = double(rest[i]) * double(rest[i]-1);
      } else {
        coeffient = double(rest[i]) * double(rest[j]);
      }
      coeffient/=denominator;
      coeffient/=(denominator-1);
      
      ans+=coeffient * winTaka(i, j, s,t);
    }
  }
  cout << ans << "\n";
  return 0;
}
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <math.h>
#include <string.h>
#include <stdlib.h>

using namespace std;

#if __cplusplus >= 201103L
    #include <unordered_set>
    #include <unordered_map>
    #include <chrono>
    #include <random>
    #include <bits/stdc++.h>
    struct pairhash {
        template<class T, class U>
        size_t operator() (const pair<T,U> &p) const {
            static const uint64_t FIXED_RANDOM = (uint64_t)chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(p.first + FIXED_RANDOM) ^ splitmix64(p.second+ FIXED_RANDOM);
        }
        static uint64_t splitmix64(uint64_t x) {
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }
    };
    mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

    inline int randint(int l, int r) {
        return uniform_int_distribution<int>(l,r)(rng);
    }

    inline double randdouble(double l, double r) {
        return uniform_real_distribution<double>(l,r)(rng);
    }
#endif
 

#define fastio ios::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define ll128 __int128_t
#define PI 3.14159265358979323846
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a<b)?(b):(a))
#define abs(a) ((a>0)?a:-(a))
#define pii pair<int,int>
#define pll pair<ll,ll>


template <typename T>
inline void read(T& x) {
    x = 0; 
    bool f = 0;
    char ch = (char)getchar();
    while (ch < '0' || ch > '9') {  // ch 不是数字时
        if (ch == '-') f = 1;        // 判断是否为负
        ch = (char)getchar();               // 继续读入
    }
    while (ch >= '0' && ch <= '9') {  // ch 是数字时
        x = x*10 + (ch&15);  // 将新读入的数字’加’在 x 的后面, ch&15等同于ch-'0'
        ch = (char)getchar();  // 继续读入
    }
    if (f) x = -x;
}

template <typename T>
inline void write(T x) {
    static int st[35];
    int top = 0;
    do {
        st[top++] = x % 10; x /= 10;
    } while (x);
    while (top) putchar(st[--top] + '0');
}

const double pi = acos(-1.0);
const double eps = (double)1e-4;

const int mod = 1e9+7;
const int maxn = 1e5+5;
const int maxm = 2e5+10;

int cnt[10];
int a[10], b[10];
int pow10[7];

bool check() {
    int s1 = 0, s2 = 0;
    for (int i = 1; i <= 9; i++) s1 += i * pow10[a[i]];
    for (int i = 1; i <= 9; i++) s2 += i * pow10[b[i]];

    return s1 > s2;
}


int main() {

    int k;
    string s,t; cin >> k >> s >> t;
    for (int i = 1; i <= 9; i++) cnt[i] = k;
    for (char c : s) {
        if (c != '#') cnt[c-'0']--, a[c-'0']++;
    }
    for (char c : t) {
        if (c != '#') cnt[c-'0']--, b[c-'0']++;
    }
    pow10[0] = 1;
    for (int i = 1; i <= 6; i++) pow10[i] = pow10[i-1] * 10;

    double all = 0.0;
    double win = 0.0;

    for (int i = 1; i <= 9; i++) {
        if (cnt[i] == 0) continue;

        cnt[i]--; a[i]++;
        for (int j = 1; j <= 9; j++) {
            if (cnt[j] == 0) continue;

            all += (double)(cnt[i]+1.0) * (double)(cnt[j]);
            b[j]++;
            if (check()) {
                win += (double)(cnt[i] + 1.0) * (double)(cnt[j]);
            }
            b[j]--;
        }
        cnt[i]++; a[i]--;
    }
    double ans = win / all;
    printf("%.10f\n",ans);
}