#include <cstdio>
using namespace std;

using LL = long long;

char s[7], t[7];

int score(const char* cards)
{
	int cnt[10];
	for(int i=0; i<10; i++) cnt[i] = i;
	for(int i=0; i<5; i++)
		cnt[cards[i] - '0'] *= 10;
	int res = 0;
	for(int x: cnt) res += x;
	return res;
}

int main()
{
	int k;
	scanf("%d%s%s", &k, s, t);
	int cnt[10];
	for(int i=1; i<10; i++) cnt[i] = k;
	for(int i=0; i<4; i++)
		cnt[s[i] - '0'] --,
		cnt[t[i] - '0'] --;
	LL win = 0LL;
	for(int x=1; x<10; x++)
		if(cnt[x])
		{
			s[4] = '0' + x;
			int sscore = score(s);
			for(int y=1; y<10; y++)
				if(cnt[y])
				{
					t[4] = '0' + y;
					if(sscore > score(t))
						win += cnt[x] * LL(cnt[y] - (x == y));
				}
		}
	LL tmp = 9LL * k - 8LL;
	printf("%.8lf\n", double(win) / tmp / double(tmp - 1LL));
	return 0;
}
#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main()
{
  int n,i;
  ll s=0,res=0;
  map<ll,ll> m;
  decltype(m)::iterator it;
  cin >> n;
  vector<ll> a(n);
  for(i=0;i<n;i++)
    cin >> a[i];
  m[0]=1;
  for(i=0;i<n;i++){
    if(i%2==0)
      s+=a[i];
    else
      s-=a[i];
    it=m.find(s);
    if(it!=m.end())
      it->second++;
    else
      m.insert(make_pair(s,1));
  }
  for(it=m.begin();it!=m.end();it++){
    s=it->second;
    res+=s*(s-1)/2;
  }
  cout << res << endl;
  return 0;
}