#include <iostream>
#include <utility>
#include <algorithm>
#include <unordered_map>
using namespace std;
 
int main(void)
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  unordered_map<int, pair<int, int>> dp;
  int N, K;
  cin >> N >> K;
  while (K > 0)
  {
    if (dp.find(N) != dp.end())
      N = dp[N].first - dp[N].second;
   	else
    {
      string &&tmp = to_string(N);
      sort(tmp.begin(), tmp.end());
      int &&small = stoi(tmp);
      reverse(tmp.begin(), tmp.end());
      int &&big = stoi(tmp);
      dp[N] = pair<int, int>(big, small);
      N = big - small;
      if (N == 0)
        break;
    }
    K--;
  }
  cout << N << '\n';
  return 0;
}
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <functional>
#include <cassert>
#include <stack>
#include <numeric>
#include <iomanip>
#include <limits>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<ll, ll> Pll;
typedef std::pair<double, double> Pdd;

#define rip(_i, _n, _s) for (int _i = (_s); _i < (int)(_n); _i++)
#define all(_l) _l.begin(), _l.end()
#define rall(_l) _l.rbegin(), _l.rend()
#define MM << " " <<

template<typename _T>
using MaxHeap = std::priority_queue<_T>;
template<typename _T>
using MinHeap = std::priority_queue<_T, std::vector<_T>, std::greater<_T>>;

template<typename _T>
inline bool chmax(_T &_l, const _T _b) {
    if (_l < _b) {
        _l = _b;
        return true;
    }
    return false;
}
template<typename _T>
inline bool chmin(_T &_l, const _T _b) {
    if (_l > _b) {
        _l = _b;
        return true;
    }
    return false;
}

template<typename _T>
void vdeb(const std::vector<_T> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename _T>
void vdeb(const std::vector<std::vector<_T>> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        // std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int n; cin >> n;
    vector<Pii> s(n), t(n);
    rip(i,n,0) {
        cin >> s[i].first >> s[i].second;
    }
    rip(i,n,0) {
        cin >> t[i].first >> t[i].second;
    }
    if(n == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    auto dist = [&](Pii &x, Pii &y) -> int {
        return (x.first-y.first)*(x.first-y.first) + (x.second-y.second)*(x.second-y.second);
    };
    auto area = [&](Pii x, Pii y) -> int {
        return x.first*y.second-x.second*y.first;
    };
    auto minu = [](Pii x, Pii y) {
        return make_pair(x.first-y.first, x.second-y.second);
    };
    auto dataset = [&](vector<Pii> &da, int a, int b) -> vector<Pii> {
        vector<Pii> ret;
        Pii x = minu(da[a], da[b]);
        ret.reserve(n-2);
        rip(i,n,0) {
            if(i == a || i ==b) continue;
            ret.push_back({dist(da[i], da[b]), area(x, minu(da[i], da[b]))});
        }
        sort(all(ret));
        return ret;
    };
    auto base = dataset(s, 0, 1);
    // vdeb(base);
    rip(i,n,0) rip(j,n,0) {
        if(i == j || dist(s[0], s[1]) != dist(t[i], t[j])) continue;
        auto tmp = dataset(t, i, j);
        // vdeb(tmp);
        if(base == tmp) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}