#include <bits/stdc++.h>
using namespace std;
using lint = long long;

template<int MOD>
class ModInt {
 public:
  int v;

  ModInt() : v(0) {}
  ModInt(long long _v) {
    v = int((-MOD < _v && _v < MOD) ? (_v) : (_v % MOD));
    if (v < 0) v += MOD; }

  friend bool operator==(const ModInt &a, const ModInt &b) { return a.v == b.v; }
  friend bool operator!=(const ModInt &a, const ModInt &b) { return a.v != b.v; }
  friend bool operator<(const ModInt &a, const ModInt &b) { return a.v < b.v; }
  friend bool operator<=(const ModInt &a, const ModInt &b) { return a.v <= b.v; }
  friend bool operator>(const ModInt &a, const ModInt &b) { return a.v > b.v; }
  friend bool operator>=(const ModInt &a, const ModInt &b) { return a.v >= b.v; }

  ModInt& operator+=(const ModInt &a) {
    if ((v += a.v) >= MOD) v -= MOD;
    return *this; }
  ModInt& operator-=(const ModInt &a) {
    if ((v -= a.v) < 0) v += MOD;
    return *this; }
  ModInt& operator*=(const ModInt &a) {
    v = 1ll * v * a.v % MOD;
    return *this; }
  ModInt& operator/=(const ModInt &a) {
    return (*this) *= inverse(a); }

  friend ModInt pow(ModInt a, long long x) {
    ModInt res = 1; assert(x >= 0);
    for (; x; x /= 2, a *= a) if (x & 1) res *= a;
    return res; }
  friend ModInt inverse(ModInt a) {
    assert(a.v != 0);
    return pow(a, MOD - 2); }

  ModInt operator+() const { return ModInt(v); }
  ModInt operator-() const { return ModInt(-v); }
  ModInt operator++() const { return *this += 1; }
  ModInt operator--() const { return *this -= 1; }

  friend ModInt operator+(ModInt a, const ModInt &b) { return a += b; }
  friend ModInt operator-(ModInt a, const ModInt &b) { return a -= b; }
  friend ModInt operator*(ModInt a, const ModInt &b) { return a *= b; }
  friend ModInt operator/(ModInt a, const ModInt &b) { return a /= b; }

  friend istream& operator>>(istream &is, ModInt &v) { is >> v.v; return is; }
  friend ostream& operator<<(ostream &os, const ModInt &v) { os << v.v; return os; }
};

const int MOD = 998244353;
using Mint = ModInt<MOD>;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int N, M;
  cin >> N >> M;

  const int MAX = 3e5;
  vector<Mint> fact(MAX);
  vector<Mint> inv(MAX);
  fact[0] = inv[0] = 1;
  for (int i = 1; i < MAX; i++) {
    fact[i] = i * fact[i - 1];
    inv[i] = Mint(1) / fact[i];
  }
  const auto C = [&](int n, int k) -> Mint {
    if (k < 0 || k > n) return 0;
    return fact[n] * inv[k] * inv[n - k];
  };

  vector<int> primes;
  vector<int> isprime(MAX, 1);
  isprime[0] = isprime[1] = 0;
  for (int i = 2; i < MAX; i++) if (isprime[i]) {
    primes.emplace_back(i);
    for (int j = i + i; j < MAX; j += i) {
      isprime[j] = 0;
    }
  }

  vector<vector<int>> pos;
  vector<int> cur;
  Mint ans = 0;

  const auto Solve = [&]() -> Mint {
    Mint res = 1;
    for (int i = 0; i < cur.size(); i++) {
      int j = i;
      while (j + 1 < cur.size() && cur[i] == cur[j + 1]) j++;
      res *= C(N + j - i, j - i + 1);
      i = j;
    }
    return res;
  };

  const auto Dfs = [&](const auto &self, lint mul, int ptr) -> void {
    if (mul <= M) ans += Solve();
    for (int i = ptr; i < primes.size() && 1ll * mul * primes[i] < MAX; i++) {
      cur.emplace_back(primes[i]);
      self(self, mul * primes[i], i);
      cur.pop_back();
    }
  };

  Dfs(Dfs, 1, 0);
  cout << ans << '\n';
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)
#define IINF
ll solve(string s){
    vector<ll> c(10);
    //REP(i,10) cards[i] = i;
    iota(c.begin(), c.end(), 0);
    for(char it : s) c[it - '0'] *= 10;
    // ll ret = 0;
    // for(auto it : cards) ret += it;
    // return ret;
    return accumulate(c.begin(), c.end(), 0LL);
}

int main(void){
    ll k, all = 0, win = 0;
    string s,t;
    cin >> k >> s >> t;
    vector<ll> cards(10, k);

    REP(i,5){
        cards[s[i] - '0']--; cards[t[i]-'0']--;
    }
    FOR(i,1,10){
        FOR(j,1,10){
            //if(cards[i] == 0 || cards[j] == 0) continue;
            s.back() = '0' + i;
            t.back() = '0' + j;
            if(solve(s) <= solve(t)) continue;
            win += cards[i] * (cards[j] - (i == j));
        }
    }

    all = 9 * k - 8;
    cout << setprecision(15) << double(win) / all / (all - 1) << endl;


    return 0;
}