#include "bits/stdc++.h"
#pragma GCC optimize "trapv"

#define int long long
#define For(i,a,b) for(int  i=a;i<b;i++)

#define pb push_back
#define endl "\n"

#define F first
#define S second

#define drink_boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v) v.begin(),v.end()

#define TEST_CASE int  t;cin>>t;while(t--)
#define debug(...) cout<<#__VA_ARGS__<<" = "; print(__VA_ARGS__);

using namespace std;
const int MOD = 1e9 + 7;

void print()  {    cout<<endl;  }
void printArray()  {    return;  }
void read() { return; }

template<typename T , typename... Args>  void print(T a , Args... arg)    {    cout << a << " " ;    print(arg...);    }

template<typename T , typename... Args> void read(T &a , Args&... arg) {   cin >> a;   read(arg...);   }

template<typename T,typename... Args> void read(vector<T>&v , Args&... arg) {  for(auto &i : v)  cin>>i;  read(arg...);  }

template<typename T,typename... Args> void printArray(vector<T>&v, Args&... arg) {   for(auto i : v)     cout<<i<<" ";   cout<<endl;  printArray(arg...);    }

int power(int a,int b) { int  res=1; while(b) { if(b&1LL) res=res*a; b>>=1LL; a=a*a; } return res; }
    
int modPower(int a,int b) { int res=1; while(b) { if(b&1L) res=(res%MOD*a%MOD)%MOD; b>>=1; a=(a%MOD*a%MOD)%MOD; } return res; }

int gcdExtended(int a,int b,int *x,int *y){ if(a==0) { *x=0,*y=1; return b; } int x1,y1; int gcd=gcdExtended(b%a,a,&x1,&y1); *x=y1-(b/a)*x1; *y = x1; return gcd; }

int modInverse(int b,int m) {int x,y; int g=gcdExtended(b,m,&x,&y); if (g != 1) return -1; return (x%m + m) % m; }

int modDivide(int a,int b,int m=MOD) { a=a%m; int inv=modInverse(b,m); if(inv==-1) return -1; else return (inv*a)%m; }

void runCase_()
{
   int n;
   read(n);
   vector<int>v(n);read(v);
   int m = 0,c = INT_MIN;
   double e= 0;
   for(int i  : v)
   {
       m += abs(i);
       c = max(c,abs(i));
       e += (i * i);
   }
    e = sqrt(e);
    cout << fixed << setprecision(10);
    print(m);
    print(e);
    print(c);
}

signed main()
{
    drink_boost;
    // TEST_CASE
    runCase_();
    return 0;
}

/** TEST CASES HERE **/
/*

*/


#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef long long int i64;

typedef long double lld;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1'000'000'000ll + 7;
const i64 mod = 998'244'353ll;

const i64 inf = 1'000'000'000'000'000'000ll;

const long double eps = 1e-8;

map<i64, i64> solve(string s, string t, i64 n) {
    map<i64, i64> r; // score -> cnt

    vector<i64> a(10);
    for (i64 i = 0; i < 4; i++) {
        a[s[i] - '0'] += 1;
    }

    vector<i64> w = a;
    for (i64 i = 0; i < 4; i++) {
        w[t[i] - '0'] += 1;
    }


    for (char c = '1'; c <= '9'; c++) {
        i64 l = n - w[c - '0'];

        a[c - '0'] += 1;

        i64 z = 0;
        for (char k = '1'; k <= '9'; k++) {
            z += pow(10, a[k - '0']) * (k - '0');
        }

        a[c - '0'] -= 1;

        r[z] += l;
    }

    return r;
}

double solve2(string s, string t, i64 n) {
    vector<i64> w(2);

    vector<i64> a(10);
    for (i64 i = 0; i < 4; i++) {
        a[s[i] - '0'] += 1;
    }

    vector<i64> b(10);
    for (i64 i = 0; i < 4; i++) {
        b[t[i] - '0'] += 1;
    }

    for (char c1 = '1'; c1 <= '9'; c1++) {
        i64 p1 = n - a[c1 - '0'] - b[c1 - '0'];
        a[c1 - '0'] += 1;

        for (char c2 = '1'; c2 <= '9'; c2++) {
            i64 p2 = n - a[c2 - '0'] - b[c2 - '0'];
            b[c2 - '0'] += 1;

            i64 s1 = 0;
            i64 s2 = 0;
            for (char k = '1'; k <= '9'; k++) {
                s1 += pow(10, a[k - '0']) * (k - '0');
                s2 += pow(10, b[k - '0']) * (k - '0');
            }

            if (s1 > s2) {
                w[0] += p1 * p2;
            }
            else {
                w[1] += p1 * p2;
            }


            b[c2 - '0'] -= 1;
        }
        a[c1 - '0'] -= 1;
    }

    return w[0] / (double)(w[0] + w[1]);
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    if (sizeof(i64) != sizeof(long long int)) {
        cerr << "i64 != long long int" << endl;
    }


    i64 n;
    cin >> n;

    string s[2];
    cin >> s[0] >> s[1];

    /*
    auto r0 = solve(s[0], s[1], n);
    auto r1 = solve(s[1], s[0], n);

    vector<i64> w(2);

    for (auto [score0, cnt0] : r0) {
        for (auto [score1, cnt1] : r1) {
            if (score0 > score1) {
                w[0] += cnt0 * cnt1;
            }
            else {
                w[1] += cnt0 * cnt1;
            }
        }
    }

    double r = w[0] / (double)(w[0] + w[1]);
    cout << r << endl;
    */
    auto r = solve2(s[0], s[1], n);
    cout << r << endl;

    return 0;
}