#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

long long calc_score(string s)
{
  long long score = 0;
  for (char c = '1'; c <= '9'; c++)
  {
    int cnt = 0;
    rep(i, s.size())
    {
      if (c == s[i])
        cnt++;
    }

    int tmp = (c - '0');
    rep(j, cnt)
    {
      tmp *= 10;
    }

    score += tmp;
  }

  return score;
}

long long calc_cases(string s, string t, int K)
{
  vector<int> rest(10, K);
  rep(i, 4)
  {
    rest[s[i] - '0']--;
  }
  rep(i, 4)
  {
    rest[t[i] - '0']--;
  }

  long long cases = rest[s[4] - '0'];
  rest[s[4] - '0']--;
  cases *= rest[t[4] - '0'];

  return cases;
}

int main()
{
  int K;
  cin >> K;

  string S, T;

  cin >> S >> T;

  vector<int> rest(10, K);
  rep(i, S.size())
  {
    rest[S[i] - '0']--;
  }
  rep(i, T.size())
  {
    rest[T[i] - '0']--;
  }

  double cases = 0;
  for (char c = '1'; c <= '9'; c++)
  {
    if (rest[c - '0'] == 0)
      continue;

    string s = S;
    s[4] = c;
    for (char c2 = '1'; c2 <= '9'; c2++)
    {
      if (rest[c2 - '0'] == 0 || (c == c2 && rest[c2 - '0'] == 1))
        continue;

      string t = T;
      t[4] = c2;

      if (calc_score(s) > calc_score(t))
      {
        cases += calc_cases(s, t, K);
      }
    }
  }

  cout << std::fixed << std::setprecision(10) << cases / (K * 9 - 8) / (K * 9 - 8 - 1) << endl;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp1  make_pair
#define     REP(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {
        ll a,b,w,mn,mx;
        cin>>a>>b>>w;
        w=w*1000;
      mx=w/a; mn=ceil(w/(b*1.00));
      if(mn>mx) cout<<"UNSATISFIABLE"<<endl;
      else cout<<mn<<" "<<mx<<endl;

    }
}
