                              //ABHISHEK AGRAWAL,BIT mesra//                    
                      //Newbie......You have to be odd to be no. ONE :)//
//Authhor: Abhishekagrawal 
//Date: 27/02/2021 
//Time: 17:30:41 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fl float
#define vll vector<ll>
#define pii pair<int,int>
#define vpll vector<pair<ll,ll>>
#define pb push_back
#define f first
#define s second
#define mll map<ll,ll>
#define mp make_pair
#define sp(n) fixed<<setprecision(n)
#define mod (ll)1000000007
#define sortv(v) sort(v.begin(),v.end())
#define INF (ll)(1e15)
#define loop(i,n) for(int i=0;i<n;i++)
#define loop1(i,n) for(int i=1;i<=n;i++)
#define rloop(n,i) for(int i=n-1;i>=0;i--)
#define sorta(a) sort(a,a+n,greater<ll>())
#define countone(n) __builtin_popcount(n)
#define numoftrailzero(n) __builtin_ctz(n)
#define maxpowoftwo(n) __builtin_clz(n)
#define leastindexwithone(n)  __builtin_ffs(n)
#define what_is(x) cerr << #x << " is " << x << endl;
#define pfv(v) cout<<v.size()<<"\n";loop(i,v.size()) cout<<v[i]<<" ";cout<<"\n";
#define pv(v) loop(i,v.size()) cout<<v[i]<<" ";
#define all(v) v.begin(),v.end()
#define mset(dp,val) memset(dp,val,sizeof(dp))
 ll test,n;ll sum,ans;
// #ifdef TESTING 
// #define DEBUG fprintf(stderr, "====TESTING====\n") 
// #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
// #define debug(...) fprintf(stderr, __VA_ARGS__) 
// #else 
// #define DEBUG 
// #define VALUE(x) 
// #define debug(...) 
// #endif
void the_happiest_place_on_earth()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
  #ifdef ENABLE_FILE_IO
    freopen("out.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
  #endif      
} 
// bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b){
//   if(a.s+2*a.f==b.s+2*b.f) return a.f>b.f;
//   return (a.s+2*a.f>b.s+2*b.f);
// }
ll powe(ll a,ll b){ll res=1;while(b>0){if(b%2 ==1){res=(res*a);}a=(a*a);b/=2;} return res;}
const int N=200040;ll a[N],b[N],c[N],par[N],Size[N],present[N],color[N];
void testcase(){
  cin>>n;
  string s,s1;
  cin>>s>>s1;
  mll m;
  loop(i,5) m[(s[i]-'0')]++,m[(s1[i]-'0')]++;
  vll v;
  loop1(i,9){
    if(m[i]==n-1) v.pb(i);
    else if(m[i]!=n) v.pb(i),v.pb(i);
  }
  ld n1=9*n-8;
  ll nn1=v.size();
  n1=(n1*(n1-1));
  // n1/=2;
  ld an=0;
  // cout<<nn1<<" ";
  set<pair<ll,ll>>ss;
  loop(i,nn1){
    loop(j,nn1){
      if(i==j) continue;
      mll m1;
      loop(l1,4) m1[(s[l1]-'0')]++;
      m1[v[i]]++;
      ll curr=0;
      loop1(ll1,9){
        ll cc1=powe(10,m1[ll1])*ll1;
        curr+=cc1;
      }
      mll m2;
      loop(l1,4) m2[(s1[l1]-'0')]++;
      m2[v[j]]++;
      ll curr1=0;
      loop1(ll1,9){
        ll cc2=powe(10,m2[ll1])*ll1;
        curr1+=cc2;
      }
      // cout<<curr<<" "<<curr1<<"\n";
      if(curr>curr1){
        ss.insert({v[i],v[j]});
      }
    }
  }
  for(auto x:ss){
    // cout<<x.f<<" "<<x.s<<"\n";
    ll n111=n-m[x.f];
    ll n222=n-m[x.s];
    if(x.s==x.f) n222--;
    n111*=n222;
    an+=n111;
  }
  // cout<<n1<<" "<<an<<" ";
  // an*=10000;
  cout<<sp(12)<<an/n1;
  return;
}

int main(){
  the_happiest_place_on_earth();
  // Today's thought: Push yourself,because no one else is going to do it for you.
  // Things are not always #000000 and #FFFFFF
  // START OF PROGRAM LOGIC
  // g++ -o a BB.cpp -DENABLE_FILE_IO;./a
  // g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -o a file_name.cpp;./a
  test=1;int t=0;
  // cin>>test;  
  while(test--){
    //cout<<"Case #"<<++t<<": ";
    testcase();
  } 
  cerr << "Time : " << 1000 *((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
  // //END OF PROGRAM LOGIC
  return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?)
    * do smth instead of nothing and stay organized
    * WRITE STUFF DOWN
    * DON'T GET STUCK ON ONE APPROACH
*/
#include<bits/stdc++.h>
using namespace std;

typedef pair<int,int> pii;
typedef pair<string,int> psi;
typedef pair<int,string> pis;
typedef array<int,2> aii;
typedef array<int,3> aiii;
typedef array<int,4> aiiii;
typedef unsigned long long ull;
typedef long long int ll;
typedef array<ll,2> all;
typedef array<ll,3> alll;
typedef array<ll,4> allll;

#define pb push_back
#define ff first
#define ss second
#define MAX 100005
#define MOD 1000000007
#define INF 1e9+100
vector<aii>adj[MAX];
vector<int> dijkstra_dag_adj[MAX];
int xMove[] = { 0,1,0,-1,1,1,-1,-1, 2, 2, -2, -2, 1, 1, -1, -1 };
int yMove[] = { 1,0,-1,0,1,-1,1,-1, 1, -1, 1, -1, 2, -2, 2, -2 };



int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.txt","w",stdout);
    cin.tie(0),cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);
    int TC=1;
    int n,m,k,q;
    //cin>>TC;
    for(int t1=1; t1<=TC; t1++)
    {
        cin>>k;
        string s,t;
        cin>>s>>t;

        int a[10]= {},b[10]= {};
        vector<int> remaining(10,k);
        for(int i=0; i<4; i++)
            a[s[i]-48]++,remaining[s[i]-48]--;
        for(int i=0; i<4; i++)
            b[t[i]-48]++,remaining[t[i]-48]--;

        double ans=0;
        for(int i=1; i<=9; i++)
        {
            if(remaining[i]>0)
            {
                double prob=double(remaining[i])/(9*k-8);
                a[i]++;
                remaining[i]--;
                int scorea=0;
                for(int j=1; j<=9; j++)
                {
                    int cur=j;
                    for(int k=0; k<a[j]; k++)
                        cur*=10;
                    scorea+=cur;
                }

                for(int l=1; l<=9; l++)
                {
                    if(remaining[l]>0)
                    {
                        b[l]++;
                        int scoreb=0;
                        for(int j=1; j<=9; j++)
                        {
                            int cur=j;
                            for(int k=0; k<b[j]; k++)
                                cur*=10;
                            scoreb+=cur;
                        }
                        b[l]--;

                        if(scorea>scoreb)
                            ans+=prob*remaining[l]/(9*k-9);
                    }
                }

                a[i]--;
                remaining[i]++;
            }
        }

        cout<<ans<<endl;
    }
    return 0;
}
