#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define pie 3.142857143
#define ll long long int
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define vi vector<int>
#define vlli vector<ll>
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fv(i,a) for(auto i:a)
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define frv(i,c) for(auto i = c.begin(); i != c.end(); i++)
vi cs(10, 0), ct(10, 0);
ll comp(ll x)
{
	ll ans = 0;
	if (x == 0)
	{
		fr(i, 1, 10)
		{
			ans += i * pow(10, cs[i]);
		}
	}
	else
	{
		fr(i, 1, 10)
		{
			ans += (i * pow(10, ct[i]));
		}
	}
	return ans;
}
void solve()
{
	ll k;
	cin >> k;
	string s, t;
	cin >> s >> t;
	fr(i, 0, 4)
	{
		ll x = s[i] - '0';
		cs[x]++;
	}
	fr(i, 0, 4)
	{
		ll x = t[i] - '0';
		ct[x]++;
	}
	vlli ans1(10, 0), ans2(10, 0);
	ll tot = 0;
	fr(i, 1, 10)
	{
		tot += k - (cs[i] + ct[i]);
		if (cs[i] + ct[i] < k)
		{
			cs[i]++;
			ans1[i] = comp(0);
			cs[i]--;
			ct[i]++;
			ans2[i] = comp(1);
			ct[i]--;
		}
		// if (ct[i] < k)
		// {
		// 	ct[i]++;
		// 	ans2[i] = comp(1);
		// 	ct[i]--;
		// }
	}
	// fr(i, 1, 10)
	// {
	// 	cout << ans1[i] << " " << ans2[i] << endl;
	// }
	tot = tot * (tot - 1);
	ll sum = 0;
	fr(i, 1, 10)
	{
		fr(j, 1, 10)
		{
			if (ans1[i] > ans2[j])
			{
				if (i != j)
					sum += ((k - (cs[i] + ct[i])) * (k - (cs[j] + ct[j])));
				if (i == j)
				{
					ll x = cs[i] + ct[i];
					x = k - x;
					sum += (x * (x - 1));
				}
			}
		}
	}
	// cout << sum << " " << tot << endl;
	double fina = (double)sum / tot;
	cout << fixed << setprecision(9);
	cout << fina << endl;

}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen ("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin >> t;
	t = 1;
	while (t--)
	{
		solve();
	}


	return 0;
}
#include<bits/stdc++.h>
// #include<atcoder/all>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
// using namespace atcoder;
typedef long long int ll;
typedef long double ld;
typedef long long lint;
const ll INF=(1LL<<62);
const ll LINF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
    ll num=1000+10;
    vector<ll>count(num,0);
    ll n,m;cin>>n>>m;

    rep(i,n){
        ll a;cin>>a;count[a]++;
    }
    rep(i,m){
        ll a;cin>>a;count[a]++;
    }

    rep(i,num){
        if(count[i]==1)cout<<i<<" ";
    }
    cout<<endl;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    // ll T;cin>>T; 
    // rep(i,T){
    //     cout<<"Case #"<<i+1<<" : ";solve();
    // }
    solve();   
}