#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i)
#define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i)
#define revrep(i,n) for(ll i=(ll)(n)-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 60) -123456789;
#define fastio cin.tie(0); ios_base::sync_with_stdio(false); cout<<fixed<<setprecision(10);
#define newl '\n'
#define YN(e) ((e)?"Yes":"No")
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
#define delif(c,pred) (c).erase(remove_if(all(c),(pred)), end(c))
template <class T,class U> bool updmax(T& a, U b) { if(b>a){ a=b; return true;} return false;}
template <class T,class U> bool updmin(T& a, U b) { if(b<a){ a=b; return true;} return false;}
inline constexpr int Mod = 1000000007;
//inline constexpr int Mod = 998244353;
#define dbg(a) cerr << #a << ": " << (a) << endl;
#define dbgs(s) cerr << #s << endl;
#define dbg1(a,n) cerr<<#a<<": "; rep(i,n) cerr<<(a)[i]<<" "; cerr<<endl;
#define dbg2(m,h,w) cerr<<#m<<":"<<endl; rep(i,(h)){ rep(j,(w))cerr<<(m)[i][j]<<" "; cerr<<endl; }
template <class T, class U> ostream& operator << (ostream& os, pair<T,U> v) {os<<v.first<<","<<v.second;return os;}
template <class T> struct vec;
template <class T> ostream& operator << (ostream& os, vec<T> v) {os<<v[0]<<","<<v[1];return os;}
template <class T, size_t N> ostream& operator << (ostream& os, array<T,N> v) {rep(i,N)os<<v[i]<<(i+1<(ll)N?" ":"");return os;}
int rng(int n) { return rand()/(RAND_MAX+1.0)*n; }
inline constexpr int offset[] = {1,0,-1,0,1};

template <class T>
struct vec {
    T x{},y{};
    vec(){}
    vec(T x, T y) : x(x),y(y) {}
    vec rotate(vec a) {
        return vec{x*a.x-y*a.y, x*a.y+y*a.x};
    }
    friend vec operator + (vec a, vec b) {
        return vec{a.x + b.x, a.y + b.y};
    }
    friend vec operator - (vec a, vec b) {
        return vec{a.x - b.x, a.y - b.y};
    }
    friend vec operator * (vec a, T m) {
        return vec{a.x*m, a.y*m};
    }
    T& operator [](int i) { return i==0 ? x : y; }
    T norm2() const { return x*x + y*y; }
    double norm() const { return sqrt(norm2()); }
    double angle(vec a) const {
        double c = (x*a.x + y*a.y)/(norm()*a.norm());
        if (cross(a) < 0) return 2*M_PI-acos(c);
        return acos(c);
    }
    T dot(vec a) const { return x*a.x + y*a.y; }
    T cross(vec a) const { return x*a.y-y*a.x; }
    bool operator < (vec a) const {
        int p = quadrant();
        int q = a.quadrant();
        if (p != q) return p < q;
        T c = cross(a);
        if (c == 0) return norm2() < a.norm2();
        return c > 0;
    }
    int quadrant() const {
        if (y == 0 && x == 0) return 0;
        if (y >= 0) return x > 0 ? 1 : 2;
        else return x < 0 ? 3 : 4;
    }
    bool operator == (vec a) const { return x == a.x && y == a.y; }
};

int main() {
    fastio;
    ll ans{};
    ll N;
    cin >> N;
    if (N == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    vector<vec<int>> s(N),t(N);
    rep(i,N) rep(j,2) cin >> s[i][j];
    rep(i,N) rep(j,2) cin >> t[i][j];

    rep(j,N) {
        rep(q,N) {
            if (q == j) continue;
            if ((t[q] - t[j]).norm2() != (s[1]-s[0]).norm2()) continue;
            vector<vec<int>> v(N);
            rep(k,N) v[k] = s[k] - s[0];

            vector<vec<int>> u(N);
            rep(k,N) u[k] = t[k] - t[j];
            rep(m,N) {
                u[m] = u[m].rotate(s[1] - s[0]);
                v[m] = v[m].rotate(t[q] - t[j]);
            }
            sort(all(u));
            sort(all(v));
            if (u == v) {
                ans = 1;
                break;
            }
        }
    }
    cout << YN(ans) << endl;
}

#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using lli = long long;
using vi = vc<int>;
using ii = pair<int,int>;

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}
lli lcm(lli a, lli b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
int popcount(lli x) { return __builtin_popcountll(x); }
lli poww(lli a, lli b){
	lli res = 1;
	while(b){ if(b&1) res = res*a; a=a*a; b/=2;}
	return res;
}


// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int rnd(int n){return uniform_int_distribution<int>(0, n-1)(rng);}

template<class t,class u>bool mmax(t&a,u b){if(a<b)a=b;return a<b;}
template<class t,class u>bool mmin(t&a,u b){if(b<a)a=b;return b<a;}
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
// ---- しゃけ ツナマヨ ('-')7

void solve(){
	lli k; cin>>k;
	string a,b; cin>>a>>b;
	vi x(10,0),y(10,0);
	fore(i,0,4)x[a[i]-'0']++;
	fore(i,0,4)y[b[i]-'0']++;
	long double w=0,tot=0;
	vv(lli,num,10,10,0);
	fore(i,1,10)fore(j,1,10){
		lli aa = k-x[i]-y[i];
		lli bb = k-x[j]-y[j];
		if(aa==0 or bb==0)continue;
		if(i!=j)num[i][j]=(aa*bb);
		else num[i][j]=(aa*(aa-1));
		tot+=num[i][j];
	}
	fore(i,1,10){
		if(k-x[i]-y[i]==0)continue;
		lli sc = 0;
		fore(ii,1,10)sc+=poww(10,x[ii]+(i==ii))*ii;
		fore(j,1,10){
				if(k-x[j]-y[j]-(j==i)==0)continue;
				lli ss=0;
				fore(ii,1,10)ss+=poww(10,y[ii]+(j==ii))*ii;
				w+=(sc>ss)*num[i][j];
		}
	}
	long double res = w/tot;
	//cout<<w<<" "<<tot<<ENDL;
	cout<<fixed<<setprecision(7)<<res<<ENDL;

}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}
