#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
//static const ll MOD=1e9+7;
static const ll MOD=998244353;
//for(i=0;i<N;i++) cin>>a[i];

class sumSegTree {
public:
  ll n, height;
  vector<ll> data;
  
  sumSegTree(ll _n) {
    n=1;
    height=1;
    while(n<_n) {
      n*=2;
      height++;
    }
    data=vector<ll>(2*n-1);
  }
  
  void add(ll i, ll x) {
    i+=n-1;
    data[i]+=x;
    while(i>0) {
      i=(i-1)/2;
      data[i]+=x;
    }
  }
  
  //[a, b):要求区間，[l, r):対象区間
  ll _sum(ll a, ll b, ll k, ll l, ll r) {
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return data[k];
    else {
      ll s=_sum(a, b, 2*k+1, l, (l+r)/2);
      ll t=_sum(a, b, 2*k+2, (l+r)/2, r);
      return s+t;
    }
  }
  
  ll sum(ll a, ll b) {
    return _sum(a, b, 0, 0, n);
  }
  
};

int main(void) {
  ll i, j, k;
  
  ll H,W,M;
  cin>>H>>W>>M;
  vector<vector<ll>> yoko(H,vector<ll>{W}),tate(W,vector<ll>({H}));
  for(i=0;i<M;i++){
    ll x,y;
    cin>>x>>y;x--;y--;
    yoko[x].push_back(y);
    tate[y].push_back(x);
  }
  for(i=0;i<H;i++) sort(yoko[i].begin(), yoko[i].end());
  for(j=0;j<W;j++) sort(tate[j].begin(), tate[j].end());
  
  ll ans=0;
  ll f=0;
  for(j=0;j<yoko[0][0];j++) ans+=tate[j][0];
  
  sumSegTree sst(W+1);
  for(j=yoko[0][0];j<W;j++) sst.add(j,1);
  for(i=0;i<tate[0][0];i++){
    ans+=sst.sum(0, yoko[i][0]);
    
    for(auto u:yoko[i]){
      if(sst.sum(u, u+1)==0)
        sst.add(u, 1);
    }
    
  }
  pt(ans);
  
}




#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> ten = { 1,10,100,1000,10000,100000 };

int solve(vector<int> a, vector<int> b) {
    ll sa = 0, sb = 0;
    for (ll i = 1; i < 10; i++) {
        sa += i * ten[a[i]];
        sb += i * ten[b[i]];
    }
    return sa > sb;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long res = 0;
    int k; cin >> k;
    string s, t;
    cin >> s >> t;
    vector<int> a(10, 0);
    vector<int> b(10, 0);
    for (auto c : s) {
        if (c != '#') {
            a[c - '0']++;
        }
    }
    for (auto c : t) {
        if (c != '#') {
            b[c - '0']++;
        }
    }
    int num = 0;
    for (int i = 1; i <= 9; i++) {
        int stop = 0;
        for (int j = 1; j <= 9; j++) {
            a[i]++, b[j]++;
            if (a[i] + b[i] <= k && a[j] + b[j] <= k) {
                ll r = solve(a, b);
                ll add = 1LL*r * (k - a[i] - b[i] + 1) * (k - a[j] - b[j] + 1);
                if (i != j) {
                    add = 1LL * r * (k - a[i] - b[i] + 1) * (k - a[j] - b[j] + 1);
                } else {
                    add = 1LL * r * (k - a[j] - b[j] + 1) * (k - a[j] - b[j] + 2);
                }
                res += 1LL * add;
                num += r;
                if (r) {
                    //cout << i << ' ' << j << ' ' << res << ' ' << add << '\n';
                }
                else {
                    //cout << "NO\n";
                }
            }
            a[i]--, b[j]--;
        }
    }
    cout << fixed << setprecision(12);
    cout << 1.0L * res / ((9.0 * k - 8.0) * (9.0 * k - 9.0)) << '\n';
    //cout << num;
    return 0;
}

/*
2
1144#
2233#
6 5 4 4
7 5 8 4
7 6 12 4
8 5 16 4
8 6 20 4
8 7 24 4
9 5 28 4
9 6 32 4
9 7 36 4
9 8 40 4
0.444444444444
*/