#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

struct condition {
    int x,y,z;
};
bool cmp(condition& a, condition& b) {
    return a.x < b.x;
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    vector<condition> con(m);
    for (int i=0; i<m; ++i)
        scanf("%d%d%d", &con[i].x, &con[i].y, &con[i].z);
    sort(con.begin(), con.end(), cmp);
    vector<vector<long long>> dp(n+1, vector<long long>(1<<n, 0));
    dp[0][0] = 1;
    int tmp_con = 0;
    for (int i=1; i<=n; ++i) {
        for (int j=0; j<(1<<n); ++j) {
            int num_1 = 0; int tmp = j;
            while (tmp) {if (tmp%2) num_1++; tmp/=2;}
            if (num_1 != i) continue;
            for (int k=0; k<n; ++k) {
                if ( (j & (1<<k)) > 0) {
                    dp[i][j] += dp[i-1][j-(1<<k)];
                }
            }
            //printf("%d %d %lld\n", i, j, dp[i][j]);
        }
        while (tmp_con<con.size() && con[tmp_con].x == i) {
            for (int j=0; j<(1<<n); ++j) {
                int num_1 = 0;
                for (int k=0; k<con[tmp_con].y; ++k) {
                    if ( (j & (1<<k)) > 0) num_1++;
                }
                if (num_1 > con[tmp_con].z) dp[i][j] = 0;
            }
            tmp_con++;
        }
    }
    printf("%lld\n", dp[n][(1<<n) -1]);
}

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
ostream& operator<<(ostream& os, lpair& h){ os << "(" << h.first << ", " << h.second << ")"; return os;}
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
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; }

void solve(){
    ll N,M;
    cin >> N >> M;
    vll X(M), Y(M), Z(M);
    rep(i,0,M) cin >> X[i] >> Y[i] >> Z[i];
    rep(i,0,M) X[i]--;
    vector<vll> dp(N+1, vll(1LL<<N, 0));
    dp[0][0] = 1;
    typedef struct {ll x,y,z; } P;
    vector<vector<P> > alt(N);
    rep(i,0,M){
        alt[X[i]].push_back({X[i], Y[i], Z[i]});
    }

    rep(i,0,N){
        rep(bit,0,1LL<<N){
            if(dp[i][bit] == 0) continue;
            rep(j,0,N){ //j: 追加する数
                if(bit & (1LL<<j)) continue;
                vll sum(N+1, 0);
                ll newbit = (bit | (1LL<<j));
                rep(k,0,N){
                    if(newbit & (1LL<<k)){
                        sum[k+1] = sum[k] + 1;
                    }else{
                        sum[k+1] = sum[k];
                    }
                }
                bool ok = true;
                for(auto &e: alt[i]){
                    if(sum[e.y] > e.z) ok = false;
                }
                if(ok){
                    dp[i+1][newbit] += dp[i][bit];
                }
            }
        }
    }
    ll ans = dp[N][(1LL<<N)-1];
    print(ans);

}

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


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
// constexpr i32 mod   = 998244353;

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

// dijkstra {{{
template < typename CostType >
class dijkstra {
  struct edge {
    int to;
    CostType cost;

    edge(int to_, CostType cost_) : to(to_), cost(cost_) {}
  };

  const CostType INF = numeric_limits<CostType>::max();

  int n;
  vector< vector<edge> > G;
  vector< CostType > ds;

  public:
  dijkstra(int n_) : n(n_), G(n_) {}

  void add_edge(int from, int to, CostType cost) {
    G[from].emplace_back(to, cost);
  }

  CostType inf() {
    return INF;
  }

  void build(int s) {
    using P = pair<CostType, int>;
    priority_queue< P, vector<P>, greater<P> > pq;

    ds.assign(n, INF);
    ds[s] = 0;
    pq.emplace(ds[s], s);

    while (!pq.empty()) {
      int v;
      CostType d;

      tie(d, v) = pq.top();
      pq.pop();

      if (ds[v] < d) continue;

      for (const edge &e : G[v]) {
        int u = e.to;
        if (ds[u] > ds[v] + e.cost) {
          ds[u] = ds[v] + e.cost;
          pq.emplace(ds[u], u);
        }
      }
    }
  }

  CostType dist(int to) {
    return ds[to];
  }

  CostType operator[](int k) {
    return dist(k);
  }
};
// }}}

void solve() {
  int r, c;
  cin >> r >> c;

  auto as = make_vector(r, c - 1, i64(0));
  cin >> as;

  auto bs = make_vector(r - 1, c, i64(0));
  cin >> bs;

  auto to_v = [&](int y, int x) {
    return y * c + x;
  };

  dijkstra<int> G(to_v(r, c));
  range(y, 0, r) range(x, 0, c - 1) {
    G.add_edge(to_v(y, x), to_v(y, x + 1), as[y][x]);
    G.add_edge(to_v(y, x + 1), to_v(y, x), as[y][x]);
  }

  range(y, 0, r - 1) range(x, 0, c) {
    G.add_edge(to_v(y, x), to_v(y + 1, x), bs[y][x]);
  }

  range(y, 0, r) range(x, 0, c) {
    range(i, 1, y + 1) {
      G.add_edge(to_v(y, x), to_v(y - i, x), i + 1);
    }
  }

  G.build(to_v(0, 0));
  i64 ans = G[to_v(r - 1, c - 1)];
  cout << ans << endl;
}

signed main() {
  solve();
}

//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
//Incase of close mle change language to c++17 or c++14

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b)
    {
        if(a==0)
        return 0;
        int res=1;
        //a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a);
            b>>=1;
            a*=a;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    string ss="110";
    int f1=1, f2=1, f3=1;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=ss[i%3])
        f1=0;
        if(s[i]!=ss[(i+1)%3])
        f2=0;
        if(s[i]!=ss[(i+2)%3])
        f3=0;
    }
    int ans=0;
    int num=power(10, 10);
    //cout<<f1<<" "<<f2<<" "<<f3<<" "<<num<<"\n";
    int l1=(n/3), l2=(n/3), l3=(n/3);
    if(n%3==0)
    l1--;
    if(n%3==2)
    l3++;
    if(f1)
    ans+=(num-l1);
    if(f2)
    ans+=(num-l2);
    if(f3)
    ans+=(num-l3);
    cout<<ans<<"\n";
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    int ans;
    for(int i=b; i>=1; --i){
        int low = (a+i-1)/i;
        int high = b/i;
        if (high - low + 1 >= 2){
            ans = i;
            break;
        }
    }
    cout << ans;
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, K;
  cin >> N >> K;
  K --;
  vector<lint> sum2(2*N-1);
  REP(i, 2*N-1) sum2[i] = min((lint)i, 2*N-2-i) + 1;
  vector<lint> sum3(3*N-2);
  sum3[0] = 1;
  FOR(i, 1, 2*N-1) sum3[i] = sum3[i-1] + sum2[i];
  FOR(i, 2*N-1, 3*N-2) sum3[i] = sum3[i-1];
  IFOR(i, N, 3*N-2) sum3[i] -= sum3[i-N];
  lint cnt = 0;
  REP(i, 3*N-2) {
    if(cnt+sum3[i] > K) {
      IFOR(j, max(i-N+1, 0LL), min((lint)i+1, 2*N-1)) {
        if(cnt + sum2[j] > K) {
          //cout << i << " " << j << " " << cnt << endl;
          cout << (lint)i-j+1 << " " << K-cnt+1+max(j-N+1, 0LL) << " " << (lint)j-(K-cnt)+1-max(j-N+1, 0LL) << endl;
          return 0;
        }
        cnt += sum2[j];
      }
      //cout << N << " " << N << " " << N << endl;
      return 0;
    }
    cnt += sum3[i];
  }
}


#include <bits/stdc++.h>
using namespace std;
int n,m,t;
int a[1005],b[1005];

int main() {
	scanf("%d %d %d",&n,&m,&t);
	for(int i=1;i<=m;i++) {
		scanf("%d %d",&a[i],&b[i]);
	}
	int x=n;
	for(int i=1;i<=m;i++) {
		n-=(a[i]-b[i-1]);
		if(n<=0) {
			printf("No");
			return 0;
		}
		n+=(b[i]-a[i]);
		n=min(x,n);
	}
	n-=t-b[m];
	if(n<=0) {
		printf("No");
	}else {
		printf("Yes");
	}
	return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(a) (a).begin(), (a).end()
#define uniq(a) (a).erase(unique(all(a)), (a).end())
#define dump(a) cerr << #a " = " << (a) << endl
using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int bit(int n) { return 1LL << n; }
int sign(int a) { return (a > 0) - (a < 0); }
int cdiv(int a, int b) { return (a - 1 + b) / b; }
template<typename T> T sq(T a) { return a * a; }
template<typename T> void fin(T a) {
    cout << a << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &a) {
    os << "(" << a.first << ", " << a.second << ")";
    return os;
}
template<typename T, typename U, typename V> ostream &operator<<(ostream &os, const tuple<T, U, V> &a) {
    os << "(" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &a) {
    os << "(";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &a) {
    os << "(";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    }
} setup;

signed main() {
    int last = 0;
    int N, M, T;
    cin >> N >> M >> T;
    int lim = N;
    vint A(M + 1), B(M + 1);
    rep(i, M) { cin >> A[i] >> B[i]; }
    A[M] = B[M] = T;
    rep(i, M + 1) {
        N -= A[i] - last;
        if (N <= 0) { fin("No"); }
        N += B[i] - A[i];
        chmin(N, lim);
        last = B[i];
    }
    fin("Yes");
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;

const ll MAX = 10;

// a^n (mod.MOD)を求める。計算量はO(logn)
ll modpow(ll a, ll n, ll MOD = mod) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1, MOD))%MOD;
    }
    return (modpow(a, n/2, MOD) * modpow(a, n/2, MOD))%MOD;
}

ll inverse(ll a) {
    return modpow(a, mod - 2);
}

ll fact[MAX];  // fact[i] : iの階乗のmod
ll inv[MAX];  // inv[i] : iの逆数のmod
ll invfact[MAX];  // invfact[i] : iの階乗の逆数のmod

void init() {
    fact[0] = 1;
    inv[0] = inv[1] = 1;
    invfact[0] = 1;
    for(ll i = 1; i < MAX; i++) {
        fact[i] = i * fact[i-1] % mod;
        if(i >= 2) {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
        invfact[i] = inverse(fact[i]);
    }
}

int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    if(n == 1) {
        out(a[0] * a[0] % mod);
        re0;
    }
    else if(n == 2) {
        ll ans = (a[0] * a[0] % mod + a[0] * a[1] % mod + a[1] * a[1] % mod) % mod;
        out(ans);
        re0;
    }

    ll x = a[0] + a[1];
    exrep(i, 2, n-1) {
        x += a[i] * modpow(2LL, i-1) % mod;
        x %= mod;
    }

    init();

    ll ans = a[0] * x % mod;
    exrep(i, 1, n-1) {
        x = ((x + 2*mod - (a[i-1] + a[i])) % mod * inv[2] % mod + a[i]) % mod;
        ans += a[i] * x;
        ans %= mod;
    }

    out(ans);
    re0;
}

    #pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>

    using namespace std;

    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())

    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }

    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m;
        ll y = 0, x = 1;
        if (m == 1) return 0;
        while (a > 1){
            ll q = a / m;
            ll t = m;
            m = a % m, a = t;
            t = y;
            y = x - q * y;
            x = t;
        }
        if (x < 0) x += m0;
        return x;
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }

    double calc(double x, vector<ll>& arr)
    {
        double ans = 0;

        for(ll i=0;i<arr.size();i++)
        {
            ans += (double)(x + arr[i]);
            ans -= (double)min((double)arr[i], 2*x);
        }
        return ans;
    }
    int main()
    {
        fast_cin();
        ll n;
        cin>>n;
        vector<ll>arr(n);
        for(ll i=0;i<n;i++)cin>>arr[i];

        double l = 0, r = 1e9 + 10;
        while(r - l >= 1e-8)
        {
            double z = (r - l)/3;
            double l1 = l + z;
            double r1 = r - z;

            double a = calc(l1, arr);
            double b = calc(r1, arr);
            if(a < b)r = r1;
            else l = l1;

            if(abs(a-b) <= 1e-8)break;

        }

        cout<<fixed<<setprecision(10)<<calc(l, arr)/(double)n<<endl;
    }


// |--------------------------------------------|
// | User - Kunal Kumar                         |
// |--------------------------------------------|

#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define pf push_front
#define ppf pop_front
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define ulli unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vulli vector<ulli>
#define vb vector<bool>
#define vpii vector<pii>
#define vpll vector<pll>
#define mod 1000000007
#define N 200001
#define modu 998244353
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define INF 1e18
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define ppc __builtin_popcount
#define ppcll __builtin_popcountll
#define endl "\n"
using namespace std;

int gcd(int a, int b)
{
    if(b==0)
        return a;

    return gcd(b,a%b);
}

//seive
bool prime_num[1000001];
void SOE(vector <int> &v)
{
    int n = 1000000;
    memset(prime_num, true, sizeof(prime_num));

    for (int p = 2; p * p <= n; p++)
    {
        if (prime_num[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime_num[i] = false;
        }
    }

    for (int p = 2; p <= n; p++)
        if (prime_num[p])
            v.pb(p);
}

bool binary_search(vector <int> v,int s, int e,int num)
{
    while(s<=e)
    {
        int mid=(s+(e-s)/2);

        if(v[mid]==num)
            return true;
        else
        if(v[mid]>num)
            e=mid-1;
        else
            s=mid+1;
    }

    return false;
}

ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}

ll modInverse(ll n,ll p)
{
    return power(n, p - 2, p);

    /*
    ll inv[maxn],finv[maxn];
    inv[1] =inv[0]= 1;
    finv[0]=finv[1]=1;
    for (int i=2; i<maxn; ++i)
        inv[i] = (m - (m/i) * inv[m%i] % m) % m;

    for (int i=2;i<maxn;++i){
        finv[i]=(inv[i]%m * finv[i-1]%m)%m;
    }

    */
}

ll factorial[200001];
ll nCr(ll n, ll r, ll p)
{
    if (n < r)
        return 0;
    if (r == 0)
        return 1;

    return (factorial[n] * (modInverse(factorial[r], p) % p) * (modInverse(factorial[n - r], p) % p))% p;
}

void addEdge(vector <int> G[], int s, int e )
{
    G[s].pb(e);
    G[e].pb(s);
}

void solve()
{
   ll n;
   cin>>n;

   double sum = 0.00;
   rep(i,1,n)
   {
       double val = (double)(1.0*i)/(double)(n*1.0);
       sum+= (double)(1.0)/(double)(val*1.0);
   }
   cout<<fixed<<setprecision(11)<<sum;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int t;
    t=1;
    //cin>>t;

    while(t--)
    {
        solve();
    }

}

// Keep Hustling!!!!!!!!!!!

#include "bits/stdc++.h"
#include<sstream>
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const long long inf = 1e18;
const ll INFL = 1e18;
const ll MOD = 1e9 + 7;

int digit(ll x) {
    int digits = 0;

    while(x > 0){
        x /= 10;
        digits++;
    }

    return digits;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;

    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}

long long modpow(long long a, long long b, long long m){
    long long ans = 1;
    while(b > 0){
        if (b % 2 == 1){
            ans *= a;
            ans %= m;
        }
        a *= a;
        a %= m;
        b /= 2;
    }
    return ans;
}

long long comb(long long x, long long y){
    int z;
    if (y == 0) return 1;
    else {
        z = modpow(x, y/2, MOD)*modpow(x, y/2, MOD)%MOD;
        if (y % 2 == 1) z = z*x%MOD;
        return z;
    }
}

vector<long long> fact(long long x){
    vector<long long> res;
    for(int i = 1;i*i <= x;i++){
        if (x % i == 0){
            res.push_back(i);
            res.push_back(x / i);
        }
    }

    return res;
}

bool isprime(int p){
    if (p == 1) return false;
    for(int i = 2;i < p;i++){
        if (p % i == 0){
            return false;
        }
    }
    return true;
}

vector<pair<long long, long long>> prime_fact(long long x){
    vector<pair<long long, long long>> res;
    for(int i = 2;i*i <= x;i++){
        if (x % i == 0){
            long long cnt = 0;
            while(x % i == 0){
                cnt++;
                x /= i;
            }
            res.push_back({i, cnt});
        }
    }
    if (x != 1){
        res.push_back({x, 1});
    }
    return res;
}

int64_t mod_inv(int64_t a, int64_t m){
    int64_t b = m, u = 1, v = 0;

    while(b){
        int64_t t = a/b;
        a -= t*b;
        swap(a, b);
        u -= t*v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;

    return u;
}

// {g, x, y}: ax + by = g
tuple<long long, long long, long long> extgcd(long long a, long long b){
    if (b == 0) return {a, 1, 0};
    long long g, x, y;
    tie(g, x, y) = extgcd(b, a % b);
    return {g, y, x - a/b*y};
}

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

//////////////////////////

int main(){
    double n;
    double ans = 0;
    cin >> n;
    for(double i = 1; i < n;i++){
        ans += n / (n - i);
    }

    cout << setprecision(10) << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while(T--) {
    lint L, R;
    cin >> L >> R;
    lint x = max(0LL, R-L-L+1);
    cout << x * (x + 1) / 2 << "\n";
  }
}

#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <string>
#include <fstream>
#include <ios>
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdlib>
#include <cstddef>
#include <cstdarg>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <cwctype>
using namespace std;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
using ll = long long;
using ull = unsigned long long;

#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v,0,sizeof(v))
#define MP(a,b) make_pair((a),(b))
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ABS(a) ((a)>0?(a):-(a))
template<class T> T MIN(const T& a, const T& b) { return a < b ? a : b; }
template<class T> T MAX(const T& a, const T& b) { return a > b ? a : b; }
template<class T> void MIN_UPDATE(T& a, const T& b) { if (a > b) a = b; }
template<class T> void MAX_UPDATE(T& a, const T& b) { if (a < b) a = b; }

constexpr int mo = 1000000007;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
vector<complex<double>> S;
vector<complex<double>> T;

bool check(int from, int to) {
	vector<complex<double>> TT;
	complex<double> offset = T[from];
	double theta = arg(T[to] - T[from]);
	for (auto p : T) {
		p -= offset;
		p /= polar(1.0, theta);
		TT.push_back(p);
	}

	for (int i = 0; i < N; ++i) {
		bool found = false;
		for (int j = 0; !found && j < N; ++j) {
			if (abs(S[i] - TT[j]) < EPS) {
				found = true;
			}
		}

		if (!found) {
			return false;
		}
	}
	return true;
}

int main() {
	std::ios::sync_with_stdio(false);

	cin >> N;
	if (N == 1) {
		cout << "Yes" << endl;
		return 0;
	}

	REP(n, N) {
		double a, b;
		cin >> a >> b;
		S.emplace_back(a, b);
	}
	complex<double> offset = S[0];
	double theta = arg(S[1] - S[0]);
	for (auto& p : S) {
		p -= offset;
		p /= polar(1.0, theta);
	}

	REP(n, N) {
		double c, d;
		cin >> c >> d;
		T.emplace_back(c, d);
	}

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (i == j) {
				continue;
			}

			if (check(i, j)) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


#include "bits/stdc++.h"
#include <chrono>
#include <random>
#define lli long long int
using namespace std;
#define mod 1000000007
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000
#define common cout << "Case #" << w+1 << ": "
#define maxn 200010

void setIO(string name) {
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

template< typename T>
void PVecPrint(vector<T>&v)
{
    for(int i=0;i<(int)v.size();i++)
        cout << v[i].first << "," << v[i].second << ' ';
    cout << '\n';
}
template<class T>
void VecPrint(vector<T>&v)
{
    for(int i=0;i<v.size();i++)
        cout << v[i] << ' ';
    cout << '\n';
}
/*-------------------------------------------------------------------Code-----------------------------------------------------------------*/

int dp[101][100001];

int main()
{
    int n;
    cin >> n;
    vector<int>v(n);
    int tot=0;
    for(int i=0;i<n;i++)
    {
        cin >> v[i];
        tot+=v[i];
    }
    for(int i=0;i<n;i++)
        for(int j=0;j<100001;j++)
            dp[i][j]=0;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=100000;j++)
        {
            if(j==0)
            {
                dp[i][j]=1;
                continue;
            }
            if(v[i-1]>j)
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=dp[i-1][j] | dp[i-1][j-v[i-1]];
        }
    }
    int ans=INF;
    for(int i=0;i<=100000;i++)
    {
        if(dp[n][i])
            ans=min(ans,max(i,tot-i));
    }
    cout << ans << '\n';
}


#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using vl = vector<long long>;
using vi = vector<int>;

int main(){
    int n; cin >> n;
    set<string> s1,s2;
    string ans = "satisfiable";
    vector<string> ss(n);
    for(int ix=0;ix<n;ix++) cin >> ss.at(ix);
    for(int ix=0;ix<n;ix++){
        string tmp = ss.at(ix);
        if(tmp.at(0) == '!'){
            if(s2.count(tmp.substr(1))){
                ans = tmp.substr(1);
                break;
            }
            else{
                s1.insert(tmp.substr(1));
            }
        }
        else{
            if(s1.count(tmp)){
                ans = tmp;
                break;
            }
            else{
                s2.insert(tmp);
            }
        }
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<string> S;
  vector<string> dict;
  rep(i,N) {
    string s;
    cin >> s;
    if(s[0] == '!') dict.push_back(s.substr(1));
    else S.push_back(s);
  }
  sort(dict.begin(), dict.end());
  for(auto s:S) {
    if(binary_search(dict.begin(), dict.end(), s)) {
      cout << s << endl;
      return 0;
    }
  }
  cout << "satisfiable" <<endl;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <string>
#include <bits/functexcept.h>
#include <iosfwd>
#include <bits/cxxabi_forced.h>
#include <bits/functional_hash.h>

#pragma push_macro("__SIZEOF_LONG__")
#pragma push_macro("__cplusplus")
#define __SIZEOF_LONG__ __SIZEOF_LONG_LONG__
#define unsigned unsigned long
#define __cplusplus 201102L

#define __builtin_popcountl __builtin_popcountll
#define __builtin_ctzl __builtin_ctzll

#include <bitset>

#pragma pop_macro("__cplusplus")
#pragma pop_macro("__SIZEOF_LONG__")
#undef unsigned
#undef __builtin_popcountl
#undef __builtin_ctzl
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<int>v[3];
    for(int i=0;i<2*n;i++){
        int x;
        cin>>x;
        char c;
        cin>>c;
        if(c=='R')v[0].push_back(x);
        else if(c=='G')v[1].push_back(x);
        else v[2].push_back(x);
    }
    if(v[0].size()%2==0&&v[1].size()%2==0){
        cout<<0;
        return 0;
    }
    if(v[0].size()%2==1){
        //cout<<1<<" ";
        if(v[1].size()%2==0)swap(v[0],v[1]);
        else swap(v[0],v[2]);
        //cout<<v[0].size()<<" ";
    }
    int ans=LLONG_MAX;
    sort(v[0].begin(),v[0].end());
    sort(v[1].begin(),v[1].end());
    sort(v[2].begin(),v[2].end());
    //cout<<v[2].size()<<" "<<v[1].size()<<endl;
    for(auto i:v[1]){
        auto j=lower_bound(v[2].begin(),v[2].end(),i)-v[2].begin();
        if(j!=v[2].size())ans=min(ans,abs(i-v[2][j]));
        if(j>0){
            ans=min(ans,abs(i-v[2][j-1]));
        }

    }
    int a[n];
    multiset<int>s;
    for(int i=0;i<v[0].size();i++){
        int x=LLONG_MAX;
        auto j=lower_bound(v[2].begin(),v[2].end(),v[0][i])-v[2].begin();
        if(j!=v[2].size())x=min(x,abs(v[0][i]-v[2][j]));
        if(j>0){
            x=min(x,abs(v[0][i]-v[2][j-1]));
        }
        s.insert(x);
    }
    for(int i=0;i<v[0].size();i++){
        int x=LLONG_MAX;
        auto j=lower_bound(v[1].begin(),v[1].end(),v[0][i])-v[1].begin();
        if(j!=v[1].size())x=min(x,abs(v[0][i]-v[1][j]));
        if(j>0){
            x=min(x,abs(v[0][i]-v[1][j-1]));
        }
        int y=LLONG_MAX;
        j=lower_bound(v[2].begin(),v[2].end(),v[0][i])-v[2].begin();
        if(j!=v[2].size())y=min(y,abs(v[0][i]-v[2][j]));
        if(j>0){
            y=min(y,abs(v[0][i]-v[2][j-1]));
        }
        auto it=s.begin();
        if(*it==y)it++;
        ans=min(ans,x+*it);
    }
    cout<<ans;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
template<class T> inline int  sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
int main()
{
  int n; cin >> n;
  vl a(2*n);
  vector<char> c(2*n);
  int Rcnt = 0, Bcnt = 0, Gcnt = 0;
  vl r,b,g;
  rep(i,2*n) {
    cin >> a[i] >> c[i];
    if(c[i] == 'R') {
      r.push_back(a[i]);
      Rcnt++;
    }
    if(c[i] == 'B') {
      b.push_back(a[i]);
      Bcnt++;
    }
    if(c[i] == 'G') {
      g.push_back(a[i]);
      Gcnt++;
    }
  }

  if(Rcnt % 2 == 0 && Bcnt % 2 == 0 && Gcnt % 2 == 0) cout << 0 << "\n";
  else {
    // RB
    if(Rcnt % 2 == 1 && Bcnt % 2 == 1) {
    }
    else if(Rcnt % 2 == 1 && Gcnt % 2 == 1) {
      swap(g, b);
    }
    else {
      swap(g, r);
    }
      ll res = infll;
      sort(b.begin(),b.end());
      rep(i,sz(r)) {
        int lb = -1, ub = sz(b);
        while(ub - lb > 1) {
          int mid = (ub + lb) / 2;
          (b[mid] >= r[i] ? ub : lb) = mid;
        }
        if(ub != sz(b)) chmin(res, abs(r[i] - b[ub]));
        if(ub != 0) chmin(res, abs(r[i] - b[ub-1]));
      }
      sort(g.begin(),g.end());
      ll tmp1 = infll/2;
      ll tmp2 = infll/2;
      rep(i,sz(r)) {
        int lb = -1, ub = sz(g);
        while(ub - lb > 1) {
          int mid = (ub + lb) / 2;
          (g[mid] >= r[i] ? ub : lb) = mid;
        }
        if(ub != sz(g)) chmin(tmp1, abs(r[i] - g[ub]));
        if(ub != 0) chmin(tmp1, abs(r[i] - g[ub-1]));
      }
      rep(i,sz(b)) {
        int lb = -1, ub = sz(g);
        while(ub - lb > 1) {
          int mid = (ub + lb) / 2;
          (g[mid] >= b[i] ? ub : lb) = mid;
        }
        if(ub != sz(g)) chmin(tmp2, abs(b[i] - g[ub]));
        if(ub != 0) chmin(tmp2, abs(b[i] - g[ub-1]));
      }
      chmin(res, tmp1+tmp2);
      cout << res << "\n";

  }

  return 0;

}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

long double times[maxn],pretimes[maxn],prob[maxn],preprob[maxn];
int blocked[maxn];

long double gettimes(int x){
	return x<0 ? 0 : pretimes[x];
}

long double getprob(int x){
	return x<0 ? 0 : preprob[x];
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n,m,k; cin>>n>>m>>k;
	for (int i=1;i<=k;i++){
		int x; cin>>x;
		blocked[x]=1;
	}

	long double sumprob=0.0,sumtimes=0.0;
	prob[0]=1,preprob[0]=1;
	for (int i=1;i<=n+m;i++){
		prob[i]=(getprob(min(i-1,n-1))-getprob(i-m-1))/m;
		//cout<<prob[i]<<'\n';
		if (!blocked[i]) preprob[i]=preprob[i-1]+prob[i];
		else preprob[i]=preprob[i-1];
		if (i>=n) sumprob+=prob[i];
	}
	//cout<<sumprob<<'\n';
	for (int i=1;i<=n+m;i++){
		times[i]=(gettimes(min(i-1,n-1))-gettimes(i-m-1))/m+prob[i];
		//cout<<times[i]<<'\n';
		if (i>=n||blocked[i]) sumtimes+=times[i];
		if (blocked[i]) pretimes[i]=pretimes[i-1];
		else pretimes[i]=pretimes[i-1]+times[i];
	}
	if (sumprob==0.0) cout<<"-1\n";
	else cout<<fixed<<setprecision(10)<<sumtimes/sumprob<<'\n';
}

/*
	I love the sound you make when you shut up.
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
/*----typedefs--------*/
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using ll = long long;
using pi = pair<int, int>;
/*-----in and out--------*/
#define pf(a) cout << a << endl
#define forIn(arr, num) for(int i = 0; i < num; i++) cin >> arr[i];
#define vpnt(ans) for(int i = 0; i < int(ans.size()); i++) cout << ans[i] << (i + 1 < int(ans.size()) ? ' ' : '\n');
/*---useful defines------*/
#define sz(x) (int)(x).size()
#define pb push_back
#define mem(a, b) memset(a,(b), sizeof(a))
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
/*----- the binary answer of life-----*/
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
/*---checking and pushing-----*/
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
/*---- FAST I/O and file read ---*/
void go() {
    ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#endif
}
/*-------- test-case stuff--------------*/
#define ssolve solve();
#define msolve int T;cin >> T;while(T--) {solve();}
#define mcsolve int T;cin >> T;for(int tt = 1;tt <= T;tt++) {cout << "Case #" << tt << ": ";solve();}
/*-------- movement in a 2D array ------*/
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
/*----------------------------------------------------------------*/
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
/*-------------- Push your limits here ---------------------------*/
int n, m, K, a[15];
bool b[N];
double c1[N], c2[N];
void add(double *c, int p, double v) {
    while(p <= n + m) {
        c[p] += v;
        p += (p & (-p));
    }
}

double ask(double *c, int p) {
    double s = 0;
    while(p) {
        s += c[p];
        p -= (p & (-p));
    }

    return s;
}

void solve() {
    cin >> n >> m >> K;

    for(int i = 1;i <= K;i++) {
        cin >> a[i];
        b[a[i]] = true;
    }

    if(m <= K) {
        for(int i=1;i+m-1<=K;++i) {
            bool flg=1;
            for(int j=1;j<m;++j)
                if(a[i+j-1]+1!=a[i+j])
                    flg=0;
            if(flg) {
                pf(-1);
                return;
            }
        }
    }

    for(int i = n - 1;i;i--) {
        if(b[i]) {
            add(c1, i, 1);
        } else {
            add(c1, i, ask(c1, i + m) / m);
            add(c2, i, ask(c2, i + m) / m + 1);
        }
    }

    double k = ask(c1, m) / m, d = ask(c2, m) / m + 1;
    cout << fixed << setprecision(4) << (d / (1 - k)) << endl;
}

int main() {
    //go();
    ssolve
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
  long double R,x,y;
  cin>>R>>x>>y;
  long double d=sqrt((x*x)+(y*y));
  long long ans=1;
  long long s=ceil(d/R);
  if(s==1&&d!=R)
  {
  	ans++;
  }
  else if(s>1)
  {
  	ans=s;
  }
  cout<<ans;
  return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <stack>
#include <vector>
#include <cctype>

typedef long long LL;
typedef unsigned long long uLL;
using namespace std;

const int int_INF = 0x7fffffe0;
const LL LL_INF = 0x7fffffffffffffe0LL;

int main()
{
    LL a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[2] - a[1] == a[1] - a[0])
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    for(auto& [x, y] : p) cin >> x >> y;
    for(int i = n; i--; ) for(int j = i; j--; ) for(int k = j; k--; ){
        auto [x1, y1] = p[i];
        auto [x2, y2] = p[j];
        auto [x3, y3] = p[k];
        x1 -= x3;
        x2 -= x3;
        y1 -= y3;
        y2 -= y3;
        if(x1 * y2 == x2 * y1){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
//#include<bits/stdc++.h>
#define int long long
constexpr long long mod = 1000000007;
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << "\n"
using namespace std;
int input() {
	int r;
	cin >> r; //scanf("%lld", &r);
	return r;
}
int n, a[234567], ans;
signed main() {
	cin >> n; for0(i, n)cin >> a[i]; sort(a, a + n);
	for0(i, n - 1)ans += (a[i + 1] - a[i]) * (i + 1) * (n - i - 1);
	puts(ans);
}


#include<bits/stdc++.h>
using namespace std;
double PI=acos(-1.0);
#define ll long long
#define pii pair<ll,ll>
const ll mod=998244353;
int a[500007];
int b[500007];
int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    ll ans=0,ans1=0;
    int num1=0,num2=0;
    for(int i=0;i<n;i++)
    {
        if(s1[i]=='0')
        {
            a[num1++]=i;
            ans++;
        }
        if(s2[i]=='0')
        {
            b[num2++]=i;
            ans1++;
        }
    }
    if(ans!=ans1)
    {
        printf("-1\n");
    }
    else
    {
        ll sum=0;
        for(int i=0;i<ans;i++)
        {
            if(a[i]>b[i])
            {
                a[i]=b[i];
                sum++;
            }
        }
        for(int i=ans-1;i>=0;i--)
        {
            if(a[i]<b[i])
            {
                a[i]=b[i];
                sum++;
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>
#include <math.h>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin() , x.end()
#define fi frist
#define se second
#define Yes() {puts("YES");return;}
#define No()  {puts("No"); return;}
#define P pair <int , int>
#define vi vector<int>
#define vvi vector<<vector<int>>
#define vs vector<string>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int INF = 1001001001;
const int mod = 1000000007;
const ld PI = 3.14159265358979;

ll gcd (ll a , ll b) {
    if (a < b) swap(a , b);
    if (b == 0) return 1;
    if (a % b == 0) return b;
    else return gcd (b , a % b);
}

bool is_prime (ll x) {
	if (x == 1) {
		return false;
	}
	if (x == 2 || x == 3 || x == 5 || x == 7) {
		return true;
	}
	if((x & 1) == 0){
		return false;
	}
	for (ll i = 3; i * i <= x; i += 2) {
		if(x % i == 0)return false;
	}
	return true;
}

bool is_2power(ll x) {
	if((x & (x - 1)) == 0) {
	    return true;
	} else {
	    return false;
	}
}

vector<int> divisor (ll x) {
	vector<int> ret;
	for (int i = 2; i * i <= x; i++) {
		while (x % i == 0) {
			ret.push_back(i);
			x /= i;
		}
	}
	if (x > 1) {
		ret.push_back(x);
	}
	return ret;
}

ll modpow (ll x , ll p , ll m) {
	ll ret = 1;
	while (p > 0) {
		if(p & 1)ret *= x;
		x *= x;
		x %= m;
		p >>= 1;
	}
	return ret;
}

int main(void){
    cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    int n;
    cin >> n;
    vi a(n) , p(n) , x(n);
    rep(i,n)cin >> a[i] >> p[i] >> x[i];
    int ans = INF;
    rep(i,n){
        if(x[i] - a[i] >= 1){
            ans = min(ans , p[i]);
        }
    }
    if(ans == INF)ans = -1;
    cout << ans << endl;
    return 0;
}


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

#define int long long
#define mod 998244353
#define pb push_back
#define S second
#define F first
#define inf 1e18
#define all(v) v.begin(), v.end()

#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n" \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int pwmd(int n, int m) {
  int res = 1;
  while (m > 0) {
    if (m & 1)
     res = (res % mod * n % mod) % mod;
    m /= 2;
    n = (n % mod * n % mod) % mod;
    }
  return res;
}

int32_t main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a,b,c;
  cin >> a >> b >> c;
  int ans = (a * (a + 1)) / 2;
  ans %= mod;
  ans = (ans * ((b * (b + 1)) % mod *pwmd(2,mod-2) % mod) % mod) % mod;
  ans = (ans * ((c * (c + 1)) % mod *pwmd(2,mod-2) % mod) % mod) % mod;
  cout << ans;
  return 0;
}

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")

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

	long long n, i, j, k, ans, nn, INF = 1LL << 60, v;
	cin >> n;
	nn = 1LL << n;
	vector<long long> x(n), y(n), z(n);
	for (i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];
	vector<vector<long long>> dist(n, vector<long long>(n));
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) dist[i][j] = abs(x[i] - x[j]) + abs(y[i] - y[j]) + max(0LL, z[j] - z[i]);
	}

	vector<vector<long long>> dp(nn, vector<long long>(n, INF));	// dp[bit mask][last city]
	dp[1][0] = 0;
	for (i = 1; i < nn; i++) {
		for (j = 0; j < n; j++) {
			if ((1LL << j) & i) {
				for (k = 0; k < n; k++) {
					if (((1LL << k) & i) == 0) {
						v = i | (1LL << k);
						dp[v][k] = min(dp[v][k], dp[i][j] + dist[j][k]);
					}
				}
			}
		}
	}

	ans = INF;
	for (i = 1; i < n; i++) ans = min(ans, dp[nn - 1][i] + dist[i][0]);
	cout << ans << "\n";

	return 0;
}


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

vector<int> MODS = {int(1e9+7), 998244353};
template <int id>
struct Modular {
  int value;

  static int MOD() {return MODS[id];}
  Modular(long long v = 0) { value = v % MOD(); if (value < 0) value += MOD();}
  Modular(long long a, long long b) : value(0) { *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD()) value -= MOD(); return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD();return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD();return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }

  friend Modular inverse(Modular b, long long m = MOD()) {
    long long u = 0, v = 1, a = b.value;
    while (a != 0) {
      long long t = m / a;
      m -= t * a; swap(a, m);
      u -= t * v; swap(u, v);
    }
    return Modular(u);
  }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};
using mint = Modular<2>;

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

  int n, k, m;
  cin >> n >> k >> m;
  MODS.push_back(m);

  vector<vector<mint>> dp(n+1, vector<mint> (1e6+10, 0));
  dp[0][0] = 1;

  for (int i = 1; i <= n; ++i) {
    vector<mint> prev = dp[i-1];
    for (int j = i; j <= 1e6; ++j) {
      prev[j] += prev[j-i];
    }

    for (int j = 0; j <= 1e6; ++j) {
      int last = j - i * k - i;

      dp[i][j] += prev[j];
      if (last >= 0) dp[i][j] -= prev[last];
    }
  }

  for (int i = 1; i <= n; ++i) {
    mint cur = 0;
    for (int j = 1; j <= 1e6; ++j) {
      cur += dp[i-1][j] * dp[n-i][j] * (k + 1);
    }
    cur += k;
    cout << cur << '\n';
  }
}

#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define printg(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int get_random() {
    static uniform_int_distribution<int> dist(0, 1e9 + 6);
    return dist(rng);
}
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}

typedef unsigned long long ull;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

template<class T>
void make_unique(T & v) {
    sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
}
int geti() { int x; cin >> x; return x; }
long long getll() { long long x; cin >> x; return x; }
double getd() { double x; cin >> x; return x; }
// pair<int, int> a(geti(), geti()) does not work
// pair<int, int> a({geti(), geti()}) works, since it uses initializer.

const int MAXN = 3e5 + 100;

void solve(int tt) {
    // cout<<"Case #"<<tt<<": ";

}

int n,m,k;

vi c[101];

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // solve_testcase;

    cin>>n>>k>>m;
    c[1] = vi(k + 1, 1);
    rep(i,2,n+1) {
    	int ub=k*i*(i+1)/2+1;
    	if(i>n+1-i) mini(ub,(int)c[n+1-i].size());
    	c[i] = vi(ub);

    	rep(j,0,c[i-1].size()) {
    		if(c[i-1][j]==0) continue;
    		rep(cc,0,k+1) {
    			if(j+cc*i >= c[i].size()) break;
    			c[i][j+cc*i]+=c[i-1][j];
    			if(c[i][j+cc*i]>=m) c[i][j+cc*i]-=m;
    		}
    	}
    }
    // rep(i,1,n+1) print(i,c[i]);

    vi res(n+1);
    res[1]=k;
    res[n]=k;
    rep(i,2,n) {
    	if(i>n+1-i) break;
    	ll tmp=0;
    	int n1=c[i-1].size();
    	int n2=c[n-i].size();
    	rep(j,0,min(n1,n2)) {
    		tmp=(tmp+(ll)c[i-1][j]*(ll)c[n-i][j]%m)%m;
    	}
    	res[i]=(tmp*(k+1)%m+m-1)%m;
    	res[n+1-i]=res[i];
    }
    rep(i,1,n+1)cout<<res[i]<<endl;

    return 0;
}


// Problem: B - Do you know the second highest mountain?
// Contest: AtCoder - Mynavi Programming Contest 2021（AtCoder Beginner Contest 201）
// URL: https://atcoder.jp/contests/abc201/tasks/abc201_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vdb vector<double>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii >
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define bloop(i,a,b) for(int i = a;i>=b;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define CHECK1(a) cout<<a<<endl
#define CHECK2(a,b) cout<<a<<' '<<b<<endl;
#define br '\n'
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
// int extendedgcd(int a,int b,int &x,int &y){
	// if(a == 0){
		// x = 0; y = 1;
		// return b;
	// }
	// int x1,y1;
	// int d = extendedgcd(b%a,a,x1,y1);
	// x = y1 - (b/a)*x1;y = x1;
	// return d;
// }
// int expmod(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = expmod(a,b/2)%mod;
// 	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
// 	return (m1*m1)%mod;
// }
// int power(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = power(a,b/2);
// 	if(b%2) return m1*m1*a;
// 	return m1*m1;
// }
// int logn(int n, int r)
// {
//     return (n > r - 1) ? 1 + logn(n / r, r) : 0;
// }

// int nCr(int n,int r)
// {
	// r = min(r,n-r);
	// if(r<0)
		// return 0;
	// if(r == 0)
		// return 1;
	// int ans = 1;
	// for(int i = 1;i<=r;i++)
	// {
		// ans = ans*(n-i+1)/i;
	// }
	// return ans;
//
// }
// vi factmod(int n)
// {
	// vi ans(n+1);
	// ans[0] = 1;
	// loop(i,1,n+1)
	// {
		// ans[i] = (ans[i-1]*i)%mod;
	// }
	// return ans;
// }
// int nCrmod(int n,int r,vi &fact)
// {
	// int x1,y1;
	// extendedgcd(fact[r],mod,x1,y1);
	// int x2,y2;
	// extendedgcd(fact[n-r],mod,x2,y2);
	// int ans = (fact[n]*((x1+mod)%mod))%mod;
	// ans = (ans*((x2+mod)%mod))%mod;
	// return ans;
// }

// void dfs(vector<vector<int> > &adj,int root,vbool &vis)
// {
// 	vis[root] = true;
// 	for(int i = 0;i<adj[root].size();i++){
// 		int v = adj[root][i];
// 		if(!vis[v])
// 			dfs(adj,v,vis);
// 	}
// }
void solve()
{
	int n;
	cin>>n;
	vector<pair<int,string> > arr(n);
	loop(i,0,n)
	{
		cin>>arr[i].S>>arr[i].F;
	}
	sort(all(arr));
	cout<<arr[n-2].S<<'\n';
}
int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

int main(){
	fast;
	int n;
	cin >> n;
	string s[n];
	map<string, bool> mp;
	for(int i = 0; i < n; ++i){
		cin >> s[i];
		mp[s[i]] = true;
	}
	for(auto k : mp){
		string a;
		a.push_back('!');
		for(auto kk : k.first)
			a.push_back(kk);
		if(mp[a]){
			cout << k.first << '\n';
			return 0;
		}
	}
	cout << "satisfiable\n";
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf=0x3f,INF=0x3f3f3f3f; const ll LLINF=0x3f3f3f3f3f3f3f3f;
#define sz(x) (int)x.size()
#define af(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x);
#define fil(x, y) fill(af(x), y);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define lc i << 1
#define rc i << 1 | 1
const int mod = 1e9 + 7;
ll fpow(ll a, ll b){ll ret=1;while(b){if(b&1)ret=ret*a%mod;a=a*a%mod,b>>=1;}return ret;}
void madd(int &a, int b){a+=b;if(a>=mod)a-=mod;}
void msub(int &a, int b){a+=mod-b;if(a>=mod)a-=mod;}
const int MM = 2e5 + 5;
void solve(){
	int n, m, t;
	cin >> n >> m >> t;
	int p = 0, f = 1, cur = n;
	while(m--){
		int x, y;
		cin >> x >> y;
		cur -= x - p;
		if (cur <= 0){
			f = 0;
			break;
		}
		cur += y - x;
		cur = min(cur, n);
		p = y;
	}
	cur -= t - p;
	if (cur <= 0) f = 0;
	cout << (f ? "Yes" : "No") << '\n';
}

int main(){
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
using ll = long long;
constexpr ll mod = 998244353;

bool solve() {
  int n, m, t;
  cin >> n >> m >> t;

  int x = n, cur = 0;
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;

    if (x <= a - cur) return false;
    x = max(0, x - (a - cur));
    x = min(n, x + (b - a));
    cur = b;
  }

  if (x <= t - cur) return false;

  return true;
}

int main() {
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main()
{
	faster;

	int n;
	cin >> n;

	vector<int> a(n + 1), b(n + 1), swapped(n + 1, 0);
	vector<int> ans;
	priority_queue<int, vector<int>, greater<int>> pq;

	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		b[a[i]] = i;
		pq.push(a[i]);
	}
	swapped[0] = 1;

	while (pq.size())
	{
		int k = pq.top();
		pq.pop();
		int pos = b[k];
		while (pos - 1 > 0 && swapped[pos - 1] == 0 && a[pos - 1] > k)
		{
			ans.push_back(pos - 1);
			b[k] = pos-1;
			int l = a[pos-1];
			b[l] = pos;
			swap(a[pos], a[pos-1]);
			swapped[pos-1] = 1;
			pos--;
		}
	}

	// for (auto x : a)
	// 	cout << x << endl;

	//cout << ans.size() << " " << n << endl;

	if (is_sorted(all(a)) && ans.size() == n-1)
	{
		for (auto x : ans)
			cout << x << endl;
	}
	else
		cout << -1 << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> P(N);
    rep(i, N) cin >> P.at(i);
    ll s = 1;
    vector<ll> ans(0);
    bool diff = false;
    rep(i, N){
        if(P.at(i) == s){
            if(i == s-1){
                cout << -1 << endl;
                return 0;
            }
            rep(j, i-s+1){
                ans.push_back(i-j);
            }
            s = i+1;
            diff = false;
        }
        else if(P.at(i) == i+1){
            cout << -1 << endl;
            return 0;
        }
        else if(P.at(i) != i+2 && !diff){
            diff = true;
        }
        else if(P.at(i) != i+1 && diff){
            cout << -1 << endl;
            return 0;
        }
    }
    if(sz(ans) != N-1){
        cout << -1 << endl;
        return 0;
    }
    rep(i, N-1){
        cout << ans.at(i) << endl;
    }
}


#include <bits/stdc++.h>

struct node
{
    char c;
    node *pre, *suf;

    node(char c) : c(c), pre(NULL), suf(NULL) {}
};

int main()
{
    std::string s;
    std::cin >> s;
    node *hd = NULL, *tl = NULL, *cur = NULL;
    bool dir = 0;
    for (std::string::iterator it = s.begin(); it != s.end(); ++it)
    {
        if (*it == 'R')
            if (!dir)
            {
                cur = hd;
                dir = 1;
            }
            else
            {
                cur = tl;
                dir = 0;
            }
        else if (!dir)
            if (hd == NULL && tl == NULL)
                hd = tl = cur = new node(*it);
            else if (*it == tl->c)
            {
                if (hd == tl)
                    hd = tl = NULL;
                else
                {
                    tl = cur = tl->pre;
                    tl->suf = NULL;
                }
            }
            else
            {
                cur = new node(*it);
                cur->pre = tl;
                tl->suf = cur;
                tl = cur;
            }
        else
        {
            if (hd == NULL && tl == NULL)
                hd = tl = cur = new node(*it);
            else if (*it == hd->c)
            {
                if (hd == tl)
                    hd = tl = cur = NULL;
                else
                {
                    hd = cur = hd->suf;
                    hd->pre = NULL;
                }
            }
            else
            {
                cur = new node(*it);
                cur->suf = hd;
                hd->pre = cur;
                hd = cur;
            }
        }
    }
    if (hd != NULL && tl != NULL)
        if (!dir)
        {
            while (hd != tl)
            {
                std::cout << hd->c;
                hd = hd->suf;
            }
            std::cout << hd->c << std::endl;
        }
        else
        {
            while (tl != hd)
            {
                std::cout << tl->c;
                tl = tl->pre;
            }
            std::cout << tl->c << std::endl;
        }
    return 0;
}

/* Piyush Sharma*/

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main()
{
    ll testcase = 1;
    // ll testcase;
    // cin >> testcase;

    while (testcase > 0)
    {
        string s;
        cin >> s;

        deque<char> myqueue;
        bool rev = false;
        for (int i = 0; i < s.length(); i++)
        {
            if (s[i] == 'R') {
                rev = rev^1;
            }
            else if ( rev ) {
                myqueue.push_front(s[i]);
            }
            else {
                myqueue.push_back(s[i]);
            }
        }

        if ( rev ) {
            reverse(myqueue.begin(), myqueue.end());
        }

        vector<char> mystack;
        for ( char c : myqueue ) {
            if ( mystack.size() >= 1 && c == mystack.back() ) {
                mystack.pop_back();
            }
            else {
                mystack.push_back(c);
            }
        }

        string res = "";
        for ( int i=0; i<mystack.size(); i++ ) {
            char c = mystack[i];
            res += c;
        }

        // cout << "final res = " << res << "\n";
        cout << res;

        testcase--;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
using namespace std;
#define LL long long
#define LD long double
#define DB double
int read(){
	char ch=getchar();int x=0,fl=1;
	for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
	for(;isdigit(ch);ch=getchar())x=(x<<3)+(x<<1)+(ch-'0');
	return x*fl;
}
const int NN=200000+17;
void open(){
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
}
void FAIL(){
	puts("-1");
	exit(0);
}

const LD EPS=1e-15;
int n,m,k;
bool cut[NN];
LD f[NN],sf[NN];
LD ans;
bool fl[NN];
int pf[NN];
LD cal(LD mid){
	for(int i=n;i<=n+m;i++)f[i]=0.0;
	for(int i=n-1;i>=0;i--){
		if(cut[i]){
			f[i]=mid;
		}else{
			f[i]=(sf[i+1]-sf[i+m+1])/(m*1.0)+1.0;
		}
		sf[i]=sf[i+1]+f[i];
	}
	return abs(f[0]-mid);
}
bool chk(){
	for(int i=n;i<=n+m;i++)fl[i]=1;
	for(int i=n+m;i>=n;i--)pf[i]=pf[i+1]+fl[i];
	for(int i=n-1;i>=0;i--){
		if(cut[i])fl[i]=0;
		else{
			fl[i]=pf[i+1]>pf[i+m+1];
		}
		pf[i]=pf[i+1]+fl[i];
	}
	return fl[0];
}

int main(){
	//open();
	srand(20210123);
	n=read();
	m=read();
	k=read();
	for(int i=1;i<=k;i++){
		int x=read();
		cut[x]=true;
	}
	if(!chk())FAIL();
	LD ll=0,rr=2e18;
	for(int tim=1;tim<=200&&ll+EPS<rr;tim++){
		LD mid=ll+(rr-ll)/3.0,mid2=rr-(rr-ll)/3.0;
		if(cal(mid)<cal(mid2))
			rr=mid2;
		else
			ll=mid;
	}
	printf("%.10Lf\n",ll);
	return 0;
}

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>
#include <unordered_map>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;
#define PI 3.14159265358979323846264338327950L

const int mod = 1000000007;

struct container{
    int bottom, top, id;
    container(int id, int bottom, int top): top(top), bottom(bottom),id(id){
    }
};

struct Data {
    int ind;
    ll time;
    Data(int ind,ll time): ind(ind),time(time){}
    bool operator<(const Data& a) const {
    return time > a.time;
    }
};

void solve(){

    ll n,k;
    cin >> n >> k;

    vector<vector<ll>> d(n,vector<ll> (n,0));
    rep(i,n){
        rep(j,n) cin >> d[i][j];
    }

    vector<int> a;
    rep(i,n-1) a.pb(i);

    int ans = 0;
    do{

        ll D = 0;

        D += d[0][a[0]+1];
        rep(i,n-2){
            D += d[a[i]+1][a[i+1]+1];
        }
        D += d[a[n-2]+1][0];

        if (D==k) ans++;

    }while(next_permutation(begin(a),end(a)));

    cout << ans;

}

int main() {
    int T = 1;
    //cin >> T;

    while (T--){
        solve();
        cout << endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	string s, t;
	cin>>n>>s>>t;

	vector<int> si, ti;
	rep(i, n) if(s[i]=='0') si.push_back(i);
	rep(i, n) if(t[i]=='0') ti.push_back(i);

	int ans=-1;
	if(si.size()==ti.size()){
		int cnt=0;
		rep(i, si.size()) if(si[i]!=ti[i]) cnt++;
		ans=cnt;
	}

	cout<<ans<<endl;

	return 0;
}

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

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int main() {
	int N;
	string S, T;
	cin >> N >> S >> T;

	string SS = S, TT = T;
	sort(SS.begin(), SS.end());
	sort(TT.begin(), TT.end());

	if(SS != TT) {
		cout << -1 << '\n';
		return 0;
	}

	int res = 0;
	// int excess_zero = 0, excess_one = 0;

	// int p = 0;
	// for(int i = 0; i < N; i++) {
	// 	if(T[i] == '0' && excess_zero > 0)
	// 		--excess_zero;

	// 	else if(T[i] == '1' && excess_one > 0)
	// 		--excess_one;

	// 	else {
	// 		while(S[p] != T[i]) {
	// 			if(S[p] == '0')
	// 				excess_zero++;
	// 			else
	// 				excess_one++;
	// 			p++;
	// 		}

	// 		debug(i, p, excess_zero, excess_one);
	// 		if(excess_zero)
	// 			res += excess_zero;
	// 		if(excess_one)
	// 			res += 1;
	// 		p++;
	// 	}
	// }

	vector<int> a, b;
	for(int i = 0; i < N; i++) {
		if(S[i] == '0')
			a.push_back(i);
		if(T[i] == '0')
			b.push_back(i);
	}

	for(int i = 0; i < (int) a.size(); i++) {
		if(a[i] != b[i])
			res++;
	}

	cout << res << '\n';
}


// SmartCoder
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void pv(vector<int> v) {
    if (v.empty()) return;
    cout << v[0];
    for (int i = 1; i < sz(v); i++) {
        cout << " " << v[i];
    }
    cout << endl;
}

void _solve(vector<int> v) {
    int n = sz(v);
    set<int> st;
    for (int i = 0; i < n; i++) {
        int num = v[i];
        for (int j = 2; j <= num; j++) {
            while (num % j == 0) {
                st.insert(j);
                num /= j;
            }
        }
        if (num != 1) st.insert(num);
    }
    vector<ll> primes(all(st));
    n = sz(primes);
    vector<ll> res;
    for (int i = 0; i < (1 << n); i++) {
        ll cur = 1;
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) != 0) cur *= primes[j];
        }
        bool valid = true;
        for (int j = 0; j < sz(v) && valid; j++) {
            if (__gcd(v[j] * 1ll, cur) == 1) valid = false;
        }

        if (valid) {
            res.pb(cur);
        }
    }
    sort(all(res));
    cout << res[0] << "\n";
}
int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    _solve(v);

    return 0;
}

#include <bits/stdc++.h>

int mod = 1e9 + 7;

int main(){
    int N;
    std::string Caa, Cab, Cba, Cbb;
    std::cin >> N >> Caa >> Cab >> Cba >> Cbb;

    std::map< std::string, int > cur;
    std::map< std::string, int > next;
    cur["AB"] = 1;

    for(int i=2; i<5; i++){
        for(auto itr=cur.begin(); itr!=cur.end(); itr++){
            std::string cur_str = itr->first;
            for(int j=0; j<cur_str.size()-1; j++){
                std::string next_str = cur_str;
                if(next_str[j] == 'A' && next_str[j+1] == 'A'){
                    next_str.insert(j+1, Caa);
                }else if(next_str[j] == 'A' && next_str[j+1] == 'B'){
                    next_str.insert(j+1, Cab);
                }else if(next_str[j] == 'B' && next_str[j+1] == 'A'){
                    next_str.insert(j+1, Cba);
                }else{
                    next_str.insert(j+1, Cbb);
                }
                next[next_str] = 1;
            }
        }
        cur = next;
        next.clear();
    }

    if(cur.size() == 1){
        std::cout << 1 << std::endl;
    }else if(cur.size() == 4){
        long long ans = 1;
        for(int i=3; i<N; i++){
            ans = (ans * 2) % mod;
        }
        std::cout << ans << std::endl;
    }else{
        std::vector< long long > ans(N+1);
        ans[0] = 0; ans[1] = 0; ans[2] = 1;
        for(int i=3; i<=N; i++){
            ans[i] = (ans[i-1] + ans[i-2]) % mod;
        }
        std::cout << ans[N] << std::endl;
    }

    return 0;
}


#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;

//----***型定義***----
using ll = long long;
using P = pair<ll,ll>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<ll>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期化時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int main(){
  int N;cin>>N;
  vector<vector<ll> > A(N,vector<ll>(2,0));
  ll ans=0;
  REP(i,0,N){
    cin>>A[i][0]>>A[i][1];
    ans+=((A[i][1]-A[i][0]+1)*(A[i][1]+A[i][0]))/2;
  }
  print(ans);

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }
long long gcd(long long a, long long b) { return (a % b) ? gcd(b, a % b) : b; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll x, y, z;
    cin >> x >> y >> z;
    cout << (y * z - 1) / x << endl;
    return 0;
}


#include <iostream>

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef HOME
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define ff first
#define ss second
#define REP(i,st,en) for (int i = st; i <= en; i++)
#define REPR(i,st,en) for (int i = st; i >= en; i--)

const int MOD = 998244353;

class Modint {
public:
	long long val;

	Modint (long long _val = 0) {
		if (_val >= MOD) _val %= MOD;
		val = _val;
	}

	Modint operator+ (Modint other) {
		return Modint(val + other.val);
	}

	void operator+= (Modint other) {
		val += other.val;
		if (val >= MOD) val %= MOD;
	}

	Modint operator- () {
		return Modint(MOD - val);
	}

	Modint operator- (Modint other) {
		return Modint(val + MOD - other.val);
	}

	void operator-= (Modint other) {
		val += MOD - other.val;
		if (val >= MOD) val %= MOD;
	}

	Modint operator* (Modint other) {
		return Modint(val * other.val);
	}

	void operator*= (Modint other) {
		val *= other.val;
		if (val >= MOD) val %= MOD;
	}

	bool operator== (Modint other) {
		return val == other.val;
	}

	bool operator!= (Modint other) {
		return val != other.val;
	}
};

Modint exp (Modint a, long long k) {
	Modint res = 1;
	while (k) {
		if (k & 1) res *= a;
		a *= a;
		k >>= 1;
	}
	return res;
}

Modint inv (Modint a) {
	return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
	out << p.val;
	return out;
}

const int maxn = 2e5;

vector<Modint> fact(maxn + 1, 1);
vector<Modint> inv_fact(maxn + 1, 1);

void preC() {
	for (int i = 2; i <= maxn; i++) {
		fact[i] = fact[i - 1] * i;
	}
	inv_fact[maxn] = inv(fact[maxn]);
	for (int i = maxn - 1; i >= 0; i--) inv_fact[i] = inv_fact[i + 1] * (i + 1);
}

Modint C(int n, int r) { // nCr % MOD
	if (n < r) return 0;
	return fact[n] * inv_fact[r] * inv_fact[n - r];
}

class MainClass {
public:

	void solve() {

		int n, m; cin >> n >> m;

		if (m == 1) {
			cout << 1;
			return;
		}

		int lgm = log2(m) + 1;

		Modint ans = 0;
		vector<Modint> dp(m + 1, 1), new_dp(m + 1);

		for (int i = 1; i <= lgm; i++) {
			fill(new_dp.begin(), new_dp.end(), 0);
			Modint curr = 0;

			for (int j = 1; j <= m; j++) {
				for (int k = 2 * j; k <= m; k += j) new_dp[k] += dp[j];
				curr += dp[j];
			}

			ans += C(n - 1, i - 1) * curr;
			dp.swap(new_dp);
		}

		cout << ans;

		return;
	}
};

int main() {
	preC();

	int test = 1; //cin >> test;
	for (int tst = 1; tst <= test; ++tst) {
		MainClass Ausmosian;

		Ausmosian.solve();
		cout << "\n";
	}

	return 0;
}

#include <bits/stdc++.h>
#define MAX_N (200000 + 5)
#define LL long long
using namespace std;
const int mod = 998244353;
int n, m;
int inv[MAX_N];
int p[MAX_N], tot;
bool is[MAX_N];
int pw[MAX_N], f[MAX_N];
int main() {
	scanf("%d%d", &n, &m);
	inv[1] = 1;
	for (int i = 2; i <= m; ++i) inv[i] = (LL)(mod - mod / i) * inv[mod % i] % mod;
	for (int i = 2; i <= m; ++i) {
		if (!is[i]) p[++tot] = i, pw[i] = 1, f[i] = n;
		for (int j = 1; i * p[j] <= m; ++j) {
			is[i * p[j]] = 1;
			if (i % p[j]) {
				pw[i * p[j]] = 1;
				f[i * p[j]] = (LL)f[i] * n % mod;
			}
			else {
				pw[i * p[j]] = pw[i] + 1;
				f[i * p[j]] = (LL)f[i] * (n + pw[i]) % mod * inv[pw[i] + 1] % mod;
				break;
			}
		}
	}
	int ans = 1;
	for (int i = 2; i <= m; ++i) ans = (ans + f[i]) % mod;
	printf("%d", ans);
	return 0;
}


#include <bits/stdc++.h>
#define PI 3.14159265359
#define lp(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef long double ld;

using namespace std;

int sum(const string &a) {
    int ret = 0;
    for (int i = 0; i < 3; i++) {
        ret += a[i] - '0';
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a, b;
    cin >> a >> b;
    cout << max(sum(a), sum(b)) << endl;
    return 0;
}

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define code                     \
	ios::sync_with_stdio(false); \
	cin.tie(0);                  \
	cout.tie(0);
#define int long long
#define endl '\n'
#define MM(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

bool isSq(int x){
	if(x<0) return 0;
	int y = sqrt(x);
	return y*y == x;
}

int32_t main()
{
	code;
	int s,p; cin>>s>>p;
	bool yes =0;
	for(int i=0;i<=sqrt(p);i++){
		if(i*(s-i)==p) {
			yes = 1;
			break;
		}
	}
	if(yes) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

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

  int t;
  cin >> t;

  const string kAtcoder = "atcoder";

  for (int i = 0; i < t; ++i) {
    string s;
    cin >> s;

    const int n = static_cast<int>(s.size());

    if (kAtcoder < s) {
      cout << 0 << '\n';
      continue;
    }

    if (s == string(n, 'a')) {
      cout << -1 << '\n';
      continue;
    }

    int j = 0;
    while (s[j] == 'a')
      ++j;

    cout << j - (s[j] > 't' ? 1 : 0) << '\n';
  }
}

#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const string S = "atcoder";

int main() {
  int cas;
  cin >> cas;
  while (cas--) {
    string s;
    cin >> s;
    if (s > S) {
      cout << 0 << '\n';
      continue;
    }
    int best = INF;
    for (int i = 0; i < SZ(s); ++i) {
      if (s[i] == 'a') continue;
      best = min(best, i);
      if (s[0] == 'a') {
        string t = string(1, 'a') + string(1, s[i]) + string(i - 1, 'a') + s.substr(i + 1);
        if (t > S) best = min(best, i - 1);
      }
    }
    if (best == INF) {
      cout << -1 << '\n';
    } else {
      cout << best << '\n';
    }
  }
  return 0;
}


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

int main(){

 float a,b,c;
 float avg;
  cin>>a>>b>>c;

  avg=(a+b+c)/3;
  if(avg==a || avg==b || avg==c){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}

 return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define pie  3.14159265
#define int long long int
#define fr(i,a,n) for(int i=a;i<n;i++)
#define vi vector<int>
#define vlli vector<ll>
#define pb push_back
#define ppb pop_back
#define all(v) v.begin(),v.end()
#define fv(i,a) for(auto i:a)

void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    int d=a+b+c-min(a,min(b,c))-max(a,max(b,c));
    if(min(a,min(b,c)) + max(a,max(b,c))== 2*d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

signed main(){;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (long long i = (a); i < (long long)(b); i++)
#define IFOR(i, a, b) for (long long i = (a); i <= (long long)(b); i++)
using namespace std;
using VL = vector<long long>;
using ll = int64_t;
ll mod(ll x,ll m){ll y=x%m;return (y>=0LL)?y:y+m;}
template<class T>bool chmin(T& a, T b){if(a>b){a=b;return true;}else return false;}
ll gcd(ll a,ll b,ll& x,ll& y)
{if(a){ll d=gcd(b%a,a,x,y);y-=(b/a)*x;swap(x,y);if(d<0LL){d=-d;x=-x;y=-y;}return d;}else{x=0;y=1;return b;}}

ll B(ll X, ll Y, ll n){
    return (2LL*X+2LL*Y)*n+X;
}

ll W(ll P, ll Q, ll n){
    return (P+Q)*n+P;
}

int main(){
    int T;
    cin>>T;
    string ans = "";
    REP(i,T){
        ll t = LLONG_MAX;
        ll X,Y,P,Q;
        cin>>X>>Y>>P>>Q;
        ll x, y;
        ll d = gcd(2LL*(X+Y), -(P+Q), x, y);
        ll u = (P+Q)/d, v = 2LL*(X+Y)/d;
        IFOR(z, P-X, P-X+Q-1LL){
            if(mod(z,d)!=0LL)continue;
            ll n = mod(z/d*x,u);
            chmin(t,B(X,Y,n));
        }
        IFOR(z, P-X-Y+1LL, P-X){
            if(mod(z,d)!=0LL)continue;
            ll m = mod(z/d*y,v);
            chmin(t, W(P,Q,m));
        }
        if(t==LLONG_MAX){
            ans += "infinity\n";
        }else{
            ans += to_string(t) + "\n";
        }
    }

    cout << ans;

    return 0;
}

#include <cstdio>
#include <algorithm>
using namespace std;
int cm;
int g;
int jl;
int m1;
long long zm;
long long get(int x,int y){
	if((y-x)%g!=0)
		return 4e18;
	int tmp=(y-x)/g;
	long long tmpans=(1ll*jl*tmp%cm+cm)%cm;
	return (1ll*tmpans*m1+x)%zm;
}
void exgcd(int a,int b,int &g,int &x,int &y){
	if(!b){
		x=1;
		y=0;
		g=a;
		return;
	}
	exgcd(b,a%b,g,y,x);
	y-=a/b*x;
}
int main(){
	int T;
	scanf("%d",&T);
	for(int jsjs=1;jsjs<=T;jsjs++){
		int x,y,p,q;
		scanf("%d%d%d%d",&x,&y,&p,&q);
		int tmp;
		exgcd(2*x+2*y,p+q,g,jl,tmp);
		m1=2*x+2*y;
		cm=(p+q)/g;
		zm=1ll*(2*x+2*y)/g*(p+q);
		long long ans=4e18+10;
		for(int now1=x;now1<x+y;now1++)
			for(int now2=p;now2<p+q;now2++)
				ans=min(ans,get(now1,now2));
		if(ans>3e18)
			printf("infinity\n");
		else
			printf("%lld\n",ans);
	}
	return 0;
}


/*
         Crimson coagulates
         Severed head bouquet
         Body incomplete
         Sealer of your fate

         Crimson calligraphy
         Written on the trees
         Creature from the grave
         Headless and hellbent for me!
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define mod  1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)

vector<vector<int>> dp;
vector<int> ht,dpt;

const int N = 1000004;
int bit[N];
void update(int i,int x)
{
         if(i>=N)return;
         bit[i] += x;
         update(i+(i&(-i)),x);
}
int get(int x)
{
         if(x==0)return 0;
         return bit[x] + get(x-(x&(-x)));
}
signed main()
{
         int n;
         cin>>n;
         int a[n+1];
         for(int i = 1 ; i < n+1 ; i++)cin>>a[i];
         set<int> s;
         vector<int> ans;
         int ix[n+1];
         for(int i = 1 ; i <= n ; i++)ix[a[i]] = i;
         memset(bit,0,sizeof bit);
         for(int i = 1 ; i <= n ; i++){
                  int curr = ix[i] + get(N-1)-get(ix[i]);
                  update(ix[i],1);
                  int j = curr;

                  while(i != j)
                  {
                           if(s.find(j-1)!=s.end()){cout<<-1<<endl;return 0;}
                           s.insert(j-1);
                           //swap(a[j],a[j-1]);
                           ans.push_back(j-1);
                           j--;
                  }
         }
         if(ans.size()!=n-1){
                  cout<<-1<<endl;
                  return 0;
         }
         for(int i : ans)cout<<i<<endl;
//         main();

}

#include <bits/stdc++.h>

using namespace std;
#define N 1000010
#define ll long long
ll n, a[N], rk[N], vis[N], ans[N];

inline void solve() {
    scanf("%lld", &n);
    int flag = 1, r = 0;
    for (int i = 1; i <= n; ++i)scanf("%lld", &a[i]), rk[a[i]] = i;
    for (int i = 1; i <= n; ++i) {
        if (!flag)break;
        for (int j = rk[i]; j > i; --j)
            if (!vis[j]) {
                vis[j] = 1, ++rk[a[j - 1]], --rk[a[j]], swap(a[j], a[j - 1]);
                ans[++r] = j - 1;
            } else {
                flag = 0;
                break;
            }
    }
    if (flag && r == n - 1) {
        for (int i = 1; i <= r; ++i)printf("%lld\n", ans[i]);
    } else puts("-1");
}

int main() {
    int T = 1;
    //scanf("%d", &T);
    while (T--)solve();
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k;
string s;
int power(int l){
	int m=1;
	for(int i=1;i<=l;i++){
		m*=2;
	}
	return m;
}
int revi(char a,char b){
	if(a=='P'&&b=='R'){
		return a;
	}
	if(a=='P'&&b=='S'){
		return b;
	}
	if(a=='S'&&b=='P'){
		return a;
	}
	if(a=='S'&&b=='R'){
		return b;
	}
	if(a=='R'&&b=='S'){
		return a;
	}
	return b;
}
void last10(){
	char c[10005];
	int m=power(k);
	for(int i=1;i<=m;i++){
		if(i%n==0){
			c[i]=s[n-1];
		}
		else{
			c[i]=s[i%n-1];
		}
	}
	while(m!=1){
		m/=2;
		for(int i=1;i<=m;i++){
			c[i]=revi(c[i*2-1],c[i*2]);
		}
	}
	cout<<c[1];
}
signed main() {
	cin>>n>>k;
	cin>>s;
	if(k>10){
		char c[205];
		for(int i=1;i<=2*n;i++){
			if(i%n==0){
				c[i]=s[n-1];
			}
			else{
				c[i]=s[i%n-1];
			}
		}
		while(k>10){
			k--;
			for(int i=1;i<=n;i++){
				c[i]=revi(c[i*2-1],c[i*2]);
			}
			for(int i=1;i<=2*n;i++){
				if(i%n==0){
					c[i]=c[n];
				}
				else{
					c[i]=c[i%n];
				}
			}
		}
		for(int i=1;i<=n;i++){
			s[i-1]=c[i];
		}
	}
	last10();

	return 0;
}

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define repn(i,n) for(int i=1;i<=n;++i)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,q,a[200010],b[200010],depth[200010],st[200010],ed[200010],to[200010],ans[200010],len=0,
n2=1,dat[800010];
vector <LL> g[200010];

void dfs(LL pos,LL par,LL d)
{
  depth[pos]=d;
  st[pos]=len++;
  to[st[pos]]=pos;
  rep(i,g[pos].size()) if(g[pos][i]!=par) dfs(g[pos][i],pos,d+1);
  ed[pos]=len-1;
}

void upd(LL k,LL lb,LL ub,LL tlb,LL tub,LL val)
{
  //if(lb==0&&ub==n2-1) cout<<tlb<<' '<<tub<<' '<<val<<"stane\n";
  if(ub<tlb||tub<lb) return;
  if(tlb<=lb&&ub<=tub)
  {
    dat[k]+=val;
    return;
  }
  upd(k*2+1,lb,(lb+ub)/2,tlb,tub,val);
  upd(k*2+2,(lb+ub)/2+1,ub,tlb,tub,val);
}

void get(LL k,LL lb,LL ub)
{
  if(lb==ub)
  {
    if(lb<n) ans[to[lb]]=dat[k];
    return;
  }
  dat[k*2+1]+=dat[k];
  dat[k*2+2]+=dat[k];
  get(k*2+1,lb,(lb+ub)/2);
  get(k*2+2,(lb+ub)/2+1,ub);
}

int main()
{
  cin>>n;
  rep(i,n-1)
  {
    scanf("%lld%lld",&a[i],&b[i]);
    g[a[i]].pb(b[i]);
    g[b[i]].pb(a[i]);
  }
  dfs(1,0,0);
  while(n2<n) n2*=2;
  cin>>q;
  LL x,y,z;
  rep(qn,q)
  {
    scanf("%lld%lld%lld",&x,&y,&z);
    --y;
    LL from=a[y],no=b[y];
    if(x==2) swap(from,no);
    if(depth[no]<depth[from]) upd(0,0,n2-1,st[from],ed[from],z);
    else
    {
      upd(0,0,n2-1,0,n-1,z);
      upd(0,0,n2-1,st[no],ed[no],-z);
    }
  }
  get(0,0,n2-1);
  repn(i,n) printf("%lld\n",ans[i]);
	return 0;
}