#include <bits/stdc++.h>
#define poi 100
#define int long long
using namespace std;
typedef long long ll;
typedef double db;
char a[poi], b[poi];
int Ahave[poi], Bhave[poi], tothave[poi];
inline int re()
{
    char c = getchar();
    int x = 0, k = 1;
    while (c < '0' || c > '9')
    {
        if (c == '-')
            k = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
        x = (x << 1) + (x << 3) + c - '0', c = getchar();
    return k * x;
}
void wr(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        wr(x / 10);
    putchar(x % 10 + '0');
}
inline int ksm(int x, int y)
{
    int ans = 1;
    for (; y; y >>= 1)
    {
        if (y & 1)
            ans = (ans * x);
        x = (x * x);
    }
    return ans;
}
int getAscore(int x)
{
    int ans = 0;
    Ahave[x]++;
    for (int i = 1; i <= 9; i++)
        ans += i * ksm(10, Ahave[i]);
    Ahave[x]--;
    return ans;
}
int getBscore(int x)
{
    int ans = 0;
    Bhave[x]++;
    for (int i = 1; i <= 9; i++)
        ans += i * ksm(10, Bhave[i]);
    Bhave[x]--;
    return ans;
}
signed main()
{
    int k = re();
    db winCase = 0, totCase = 0;
    scanf("%s%s", a, b);
    for (int i = 0; i < 4; i++)
    {
        Ahave[a[i] - '0']++;
        Bhave[b[i] - '0']++;
        tothave[a[i] - '0']++;
        tothave[b[i] - '0']++;
    }
    for (int i = 1; i <= 9; i++)
        for (int j = 1; j <= 9; j++)
        {
            int Ascore = getAscore(i);
            int Bscore = getBscore(j);
            int thisCase = max(0ll, k - tothave[i]);
            thisCase *= max(0ll, k - tothave[j]);
            if (i == j)
                thisCase = max(0ll, k - tothave[i]) * max(0ll, k - tothave[i] - 1);
            if (Ascore > Bscore)
                winCase += thisCase;
            totCase += thisCase;
        }
    printf("%.7f", winCase / totCase);
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
    string sep = " ";
    if(v.size()) os << v[0];
    for(int i=1; i<v.size(); i++) os << sep << v[i];
    return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
    for(int i=0; i<v.size(); i++) is >> v[i];
    return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
    cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

bool dfs(int u, int c, int s, vector<vector<int>> &a, vector<int> &cs){
    int n = a.size();
    cs[u] = c;
    for(int v=0; v<n; v++){
        if(s>>v&1) continue;
        if(a[u][v]==0) continue;
        if(cs[v]==c) return false;
        if(cs[v]<0){
            if(!dfs(v, 1-c, s, a, cs)){
                return false;
            }
        }
    }

    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(n));
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        a[x-1][y-1] = 1;
        a[y-1][x-1] = 1;
    }

    ll ans = 0;
    for(int s=0; s<(1<<n); s++){
        bool ok = true;
        for(int i=0; i<n; i++){
            if((s>>i&1)==0) continue;
            for(int j=i+1; j<n; j++){
                if((s>>j&1)==0) continue;
                if(a[i][j]) ok = false;
            }
        }
        if(!ok) continue;

        ll x = 1;
        vector<int> cs(n, -1);
        for(int i=0; i<n; i++){
            if(s>>i&1) continue;
            if(cs[i]>=0) continue;
            if(dfs(i, 0, s, a, cs)){
                x *= 2;
            } else {
                x = 0;
            }
        }
        dbg(s, x);
        ans += x;
    }

    cout << ans << endl;

    return 0;
}