#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, k = 0, N = n;
        ll w = ceil(pow(N, 1./3));

        while(d <= w + 1){
            ll f = 0;

            while(n % d == 0){
                n /= d;

                ans.push_back(d);
                if(f == 0){
                    f = 1;
                    k++;
                }
            }
            d++;
        }
        //cout << n << ' ' << k << endl;
        if(n > 1){
            ans.push_back(n);
            k++;
        }
        sort(ans.begin(), ans.end());
        //cout << k << ' ' << ans.size() << endl;
        //cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
        if(k >= 3){
            ll a = ans[0], i = 1;
            while(ans[i] == a){
                a *= ans[0];
                i++;
            }
            ll b = ans[i], j = i;
            i++;
            while(ans[i] == b){
                b *= ans[j];
                i++;
            }
            ll c = ans[i];
            j = i;
            i++;
            while(i < ans.size()){
                c *= ans[i];
                i++;
            }
            cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
        }
        if(k == 2){
            if(ans.size() > 3){
                ll a = ans[0], c = ans[ans.size() - 1], b = ans[1];
                for(ll i = 2; i<ans.size()-1; i++){
                    b *= ans[i];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
        if(k == 1){
            if(ans.size() >= 6){
                ll a = ans[0], b = ans[0] * ans[0], c = 1;
                for(ll i = 3; i<ans.size(); i++){
                    c *= ans[0];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, k = 0, N = n;

        while(d*d*d <= N){
            ll f = 0;

            while(n % d == 0){
                n /= d;

                ans.push_back(d);
                if(f == 0){
                    f = 1;
                    k++;
                }
            }
            d++;
        }
        // cout << n << ' ' << k << endl;
        if(n > 1){
            ans.push_back(n);
            k++;
        }
        sort(ans.begin(), ans.end());
        //cout << k << ' ' << ans.size() << endl;
        //cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
        if(k >= 3){
            ll a = ans[0], i = 1;
            while(ans[i] == a){
                a *= ans[0];
                i++;
            }
            ll b = ans[i], j = i;
            i++;
            while(ans[i] == b){
                b *= ans[j];
                i++;
            }
            ll c = ans[i];
            j = i;
            i++;
            while(i < ans.size() && ans[i] == c){
                c *= ans[j];
                i++;
            }
            cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
        }
        if(k == 2){
            if(ans.size() > 3){
                ll a = ans[0], c = ans[ans.size() - 1], b = ans[1];
                for(ll i = 2; i<ans.size()-1; i++){
                    b *= ans[i];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
        if(k == 1){
            if(ans.size() >= 6){
                ll a = ans[0], b = ans[0] * ans[0], c = 1;
                for(ll i = 3; i<ans.size(); i++){
                    c *= ans[0];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, k = 0, N = n;
        ll w = ceil(pow(N, 1./2));

        while(d <= w + 1){
            ll f = 0;

            while(n % d == 0){
                n /= d;

                ans.push_back(d);
                if(f == 0){
                    f = 1;
                    k++;
                }
            }
            d++;
        }
        //cout << n << ' ' << k << endl;
        if(n > 1){
            ans.push_back(n);
            k++;
        }
        sort(ans.begin(), ans.end());
        //cout << k << ' ' << ans.size() << endl;

        //for(ll i = 0; i<ans.size(); i++)
          //  cout << ans[i] << ' ';
        cout << endl;

        if(k >= 3){
            ll a = ans[0], i = 1, c = 1;
            while(ans[i] == a){
                c *= ans[i];
                i++;
            }
            ll b = ans[i], j = i;
            i++;
            while(ans[i] == b){
                c *= ans[i];
                i++;
            }
            j = i;
            while(i < ans.size()){
                c *= ans[i];
                i++;
            }
            cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
        }
        if(k == 2){
            if(ans.size() > 3){
                ll a = ans[0], c = ans[ans.size() - 1], b = ans[1];
                for(ll i = 2; i<ans.size()-1; i++){
                    b *= ans[i];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
        if(k == 1){
            if(ans.size() >= 6){
                ll a = ans[0], b = ans[0] * ans[0], c = 1;
                for(ll i = 3; i<ans.size(); i++){
                    c *= ans[0];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, k = 0, N = n;
        ll w = ceil(pow(N, 1./3));

        while(d <= w){
            ll f = 0;

            while(n % d == 0){
                n /= d;

                ans.push_back(d);
                if(f == 0){
                    f = 1;
                    k++;
                }
            }
            d++;
        }
        //cout << n << ' ' << k << endl;
        if(n > 1){
            ans.push_back(n);
            k++;
        }
        sort(ans.begin(), ans.end());
        //cout << k << ' ' << ans.size() << endl;
        //cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
        if(k >= 3){
            ll a = ans[0], i = 1;
            while(ans[i] == a){
                a *= ans[0];
                i++;
            }
            ll b = ans[i], j = i;
            i++;
            while(ans[i] == b){
                b *= ans[j];
                i++;
            }
            ll c = ans[i];
            j = i;
            i++;
            while(i < ans.size()){
                c *= ans[j];
                i++;
            }
            cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
        }
        if(k == 2){
            if(ans.size() > 3){
                ll a = ans[0], c = ans[ans.size() - 1], b = ans[1];
                for(ll i = 2; i<ans.size()-1; i++){
                    b *= ans[i];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
        if(k == 1){
            if(ans.size() >= 6){
                ll a = ans[0], b = ans[0] * ans[0], c = 1;
                for(ll i = 3; i<ans.size(); i++){
                    c *= ans[0];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, k = 0;

        while(d*d*d <= n){
            ll f = 0;

            while(n % d == 0){
                n /= d;

                ans.push_back(d);
                if(f == 0){
                    f = 1;
                    k++;
                }
            }
            d++;
        }
        // cout << n << ' ' << k << endl;
        if(n > 1){
            ans.push_back(n);
            k++;
        }
        sort(ans.begin(), ans.end());
        //cout << k << ' ' << ans.size() << endl;
        //cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
        if(k >= 3){
            ll a = ans[0], i = 1;
            while(ans[i] == a){
                a *= ans[0];
                i++;
            }
            ll b = ans[i], j = i;
            i++;
            while(ans[i] == b){
                b *= ans[j];
                i++;
            }
            ll c = ans[i];
            j = i;
            i++;
            while(ans[i] == c){
                c *= ans[j];
                i++;
            }
            cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
        }
        if(k == 2){
            if(ans.size() > 2){
                ll a = ans[0], c = ans[ans.size() - 1], b = ans[1];
                for(ll i = 2; i<ans.size()-1; i++){
                    b *= ans[i];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
        if(k == 1){
            if(ans.size() >= 6){
                ll a = ans[0], b = ans[0] * ans[0], c = 1;
                for(ll i = 3; i<ans.size(); i++){
                    c *= ans[0];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, k = 0, N = n;
        ll w = ceil(pow(N, 1./2));

        while(d <= w + 1){
            ll f = 0;

            while(n % d == 0){
                n /= d;

                ans.push_back(d);
                if(f == 0){
                    f = 1;
                    k++;
                }
            }
            d++;
        }
        //cout << n << ' ' << k << endl;
        if(n > 1){
            ans.push_back(n);
            k++;
        }
        sort(ans.begin(), ans.end());
        //cout << k << ' ' << ans.size() << endl;
        //cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
        if(k >= 3){
            ll a = ans[0], i = 1;
            while(ans[i] == a){
                a *= ans[0];
                i++;
            }
            ll b = ans[i], j = i;
            i++;
            while(ans[i] == b){
                b *= ans[j];
                i++;
            }
            ll c = ans[i];
            j = i;
            i++;
            while(i < ans.size()){
                c *= ans[i];
                i++;
            }
            cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
        }
        if(k == 2){
            if(ans.size() > 3){
                ll a = ans[0], c = ans[ans.size() - 1], b = ans[1];
                for(ll i = 2; i<ans.size()-1; i++){
                    b *= ans[i];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
        if(k == 1){
            if(ans.size() >= 6){
                ll a = ans[0], b = ans[0] * ans[0], c = 1;
                for(ll i = 3; i<ans.size(); i++){
                    c *= ans[0];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, f = 0;

        while(d*d*d <= n){
            ll dd = 1, k = 0;
            while(n % d == 0){
                n /= d;

                dd *= d;
                k++;
            }

            if(dd != 1){
                ans.push_back(dd);
            }

            if(k >= 6 && ans.size() == 1){
                cout << "YES\n" << d << ' ' << d * d << ' ' << n * dd / d / d / d << "\n";
                f = 1;
                break;
            }

            d++;

            if(ans.size() == 2){
                cout << "YES\n" << ans[0] << ' ' << ans[1] << ' ' << n << "\n";
                f = 1;
                break;
            }
        }

        if(!f)
            cout << "NO\n";
    }
}


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

int main()
{
 int t;
 cin>>t;

 while(t--)
 {
  int n,i,k,x,y,z;
  cin>>n;
  k=n;

  set<long long>s;
  set<long long>::iterator it;
  for(i=2;i*i<=n;i++)
  {
    if(n%i==0)
    {
      s.insert(i);
      n=n/i;
    }
    if(s.size()==2)
      break;
  }
  if(s.size()==2)
  {
  it=s.begin();
  x=*it;
  it++;
  y=*it;
  z=k/x;
  z=z/y;
  if(z>=2 && z!=x && z!=y)
  {
    cout<<"YES"<<endl<<x<<" "<<y<<" "<<z<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }}
  else
  {
    cout<<"NO"<<endl;
  }

}
}


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

    int main()
    {
     int t;
     cin>>t;

     while(t--)
     {
      int n,i,l,m,r;
      cin>>n;
      vector<int>v;
      for(i=2;i*i<=n;i++)
      {
        if(n%i==0)
        {
          v.push_back(i);
          n=n/i;
        }
        if(v.size()==2)
          break;
      }
      if(v.size()<2)
        cout<<"NO"<<endl;
      else
      {
        l=r%(v[0]*v[1]);
        m=r/(v[0]*v[1]);
        if(l==0)
        {
    	  if(m!=v[0] && m!=v[1])
          { cout<<"YES"<<endl;
           cout<<v[0]<<" "<<v[1]<<" "<<m<<endl;}
           else
           {
    		   cout<<"NO"<<endl;}
        }
        else
          cout<<"NO"<<endl;
      }
     }
    }


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

int main()
{
 int t;
 cin>>t;

 while(t--)
 {
  int n,i,k,x,y,z;
  cin>>n;
  k=n;

  set<long long>s;
  set<long long>::iterator it;
  for(i=2;i*i<=n;i++)
  {
    if(n%i==0)
    {
      s.insert(i);
      n=n/i;
    }
    if(s.size()==2)
      break;
  }
  if(s.size()==2)
  {
  it=s.begin();
  x=*it;
  it++;
  y=*it;
  z=k/(x*y);
  if(z>=2 && z!=x && z!=y)
  {
    cout<<"YES"<<endl<<x<<" "<<y<<" "<<z<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }}
  else
  {
    cout<<"NO"<<endl;
  }

}
}


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

int main()
{
 int t;
 cin>>t;

 while(t--)
 {
  int n,i,k,x,y,z;
  cin>>n;
  k=n;

  set<long long>s;
  set<long long>::iterator it;
  for(i=2;i*i<=n;i++)
  {
    if(n%i==0)
    {
      s.insert(i);

    }
    if(s.size()==2)
      break;
  }
  if(s.size()==2)
  {
  it=s.begin();
  x=*it;
  it++;
  y=*it;
  z=k/x;
  z=z/y;
  if(z>=2 && z!=x && z!=y)
  {
    cout<<"YES"<<endl<<x<<" "<<y<<" "<<z<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }}
  else
  {
    cout<<"NO"<<endl;
  }

}
}


    #include<iostream>
    using namespace std;

    int main()
    {
    	int t;
    	int n;
    	cin>>t;
    	int i,j,count=0;
    	int p=1;
    	int k[500];

    	int a,b,c;

    	while(t--)
    	{
    	       cin>>n;
    		cin>>a>>b>>c;

    		for(i=2; ;i++)
    		{
    			for(j=0; ;j++)
    			{
    			   if(n%i==0)
    			   {
    				count++;
    				k[j]=i;
    			   }
    		    }
    		}
    		if(count==3){
    		cout<<"YES"<<endl;
    		for(j=0;j<3;j++){
    		cout<<k[j]<<" ";}
    		      cout<<endl;
    		}

            else
            cout<<"NO"<<endl;
    	}
    }


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

    int main()
    {
     int t;
     cin>>t;

     while(t--)
     {
      int n,i,l,m,r;
      cin>>n;
      r=n;
      vector<int>v;
      for(i=2;i*i<=n;i++)
      {
        if(n%i==0)
        {
          v.push_back(i);
          n=n/i;
        }
        if(v.size()==2)
          break;
      }
      if(v.size()<2)
        cout<<"NO"<<endl;
      else
      {
        l=n%(v[0]*v[1]);
        m=n/(v[0]*v[1]);
        if(l==0)
        {
    	  if(m!=v[0] && m!=v[1])
          { cout<<"YES"<<endl;
           cout<<v[0]<<" "<<v[1]<<" "<<m<<endl;}
           else
           {
    		   cout<<"NO"<<endl;}
        }
        else
          cout<<"NO"<<endl;
      }
     }
    }


#include<iostream>
using namespace std;

int main()
{
	int t;
	double n;
	cin>>t;
	int i,j,count=0;
	int p=1;
	int k[500];

	int a,b,c;

	while(t--)
	{
	       cin>>n;
		cin>>a>>b>>c;

		for(i=2; ;i++)
		{
			for(j=0; ;j++)
			{
			   if(n%i==0)
			   {
				count++;
				k[j]=i;
			   }
		    }
		}
		if(count==3){
		cout<<"YES"<<endl;
		for(j=0;j<3;j++){
		cout<<k[j]<<" ";}
		      cout<<endl;
		}

        else
        cout<<"NO"<<endl;
	}
}


#include<iostream>

using namespace std;

int main()
{
	int t,n;
	int i,count=0;
	cin>>t;
	int a[n];

	while(t--){
		cin>>n;
		for(i=1;i<=n;i++)
            cin>>a[i];
		for(i=2;i<n;i++)
		{
			if(n%i==0){
			count++;
            a[count++]=i;}
		}
		if(count<3){
			cout<<"NO"<<endl;
		}
		else
		{
			cout<<"YES"<<endl;
			for(i=1;i<4;i++)
			cout<<a[i]<<" ";
		}
		cout<<endl;

	}
}


#include<iostream>
using namespace std;

ínt main()
{
	int t;
	cin>>t;
	int i;
	int p=1;
	int a[1000];

	int a,b,c;

	while(t--)
	{
		cin>>a>>b>>c;

		for(i=2; ;i++)
		{
			for(j=0; ;j++)
			{
			   if(n%i==0)
			   {
				count++;
				a[j]=i;
			   }
		    }
		}
		if(count==3){
		cout<<"YES"<<endl;
		for(j=0;j<3;j++)
		cout<<a[j]<<" "<<endl;}

        else
        cout<<"NO"<<endl;
	}
}


#include<iostream>
using namespace std;

int main()
{
	int t;
	cin>>t;
	int i;
	int p=1;
	int a[1000];

	int a,b,c;

	while(t--)
	{
		cin>>a>>b>>c;

		for(i=2; ;i++)
		{
			for(j=0; ;j++)
			{
			   if(n%i==0)
			   {
				count++;
				a[j]=i;
			   }
		    }
		}
		if(count==3){
		cout<<"YES"<<endl;
		for(j=0;j<3;j++)
		cout<<a[j]<<" "<<endl;}

        else
        cout<<"NO"<<endl;
	}
}


    #include<iostream>
    using namespace std;

    int main()
    {
    	int t;
      int n;
    	cin>>t;
    	int i,j,count=0;
    	int p=1;

    	int a,b,c;

    	while(t--)
    	{
    	       cin>>n;
    		cin>>a>>b>>c;

    		for(i=2; ;i++)
    		{
    			for(j=0; ;j++)
    			{
    			   if(n%i==0)
    			   {
    				count++;

    			   }
    		    }
    		}
    		if(count==3){
    		cout<<"YES"<<endl;
    		}

            else
            cout<<"NO"<<endl;
    	}
    }


#include<iostream>

using namespace std;

int main()
{
	int t,n;
	int i,count=0;
	cin>>t;
	int a[n];

	while(t--){
		cin>>n;
        cin>>a;
		for(i=2;i<n;i++)
		{
			if(n%i==0){
			count++;
            a[count++]=i;}
		}
		if(count<3){
			cout<<"NO"<<endl;
		}
		else
		{
			cout<<"YES"<<endl;
			for(i=1;i<4;i++)
			cout<<a[i]<<" ";
		}
		cout<<endl;

	}
}


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

int main()
{
 int t;
 cin>>t;

 while(t--)
 {
  int n,i,l,m;
  cin>>n;
  vector<int>v;
  for(i=2;i*i<=n;i++)
  {
    if(n%i==0)
    {
      v.push_back(i);
    }
    if(v.size()==2)
      break;
  }
  if(v.size()<2)
    cout<<"NO"<<endl;
  else
  {
    l=n%(v[0]*v[1]);
    m=n/(v[0]*v[1]);
    if(l==0)
    {
	  if(m!=v[0] && m!=v[1])
      { cout<<"YES"<<endl;
       cout<<v[0]<<" "<<v[1]<<" "<<m<<endl;}
       else
       {
		   cout<<"NO"<<endl;}
    }
    else
      cout<<"NO"<<endl;
  }
 }
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {
    class Dragon implements Comparable<Dragon> {
        int life, bonus;

        public Dragon(int life, int bonus) {
            this.life = life;
            this.bonus = bonus;
        }

        @Override
        public int compareTo(Dragon o) {
            return o.bonus - bonus;
        }
    }

    public void solve() {
        Scanner input = new Scanner(System.in);

        int s = input.nextInt(), n = input.nextInt();

        Dragon[] d = new Dragon[n];
        for (int i = 0; i < n; i++) {
            int xi = input.nextInt(), yi = input.nextInt();
            d[i] = new Dragon(xi, yi);
        }
        Arrays.sort(d);
        boolean ok = true;
        boolean[] used = new boolean[n];
        for(int i = 0; i < n; i++) {
            if(d[i].life < s) {
                s += d[i].bonus;
                used[i] = true;
            }
        }
        while(true) {
            int has = 0, yet = 0;
            for(int i = 0; i < n; i++) {
                if(!used[i]) {
                    yet += 1;
                }
                if(d[i].life < s && !used[i]) {
                    s += d[i].bonus;
                    has += 1;
                    used[i] = true;
                }
            }
            if(yet >= 1 && has == 0) {
                ok = false;
                break;
            }
            if(has == 0) {
                break;
            }
        }
        if(ok) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        input.close();
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {
    class Dragon implements Comparable<Dragon> {
        int life, bonus;

        public Dragon(int life, int bonus) {
            this.life = life;
            this.bonus = bonus;
        }

        @Override
        public int compareTo(Dragon o) {
            if (life != o.life) {
                return o.life - o.life;
            }
            return bonus - o.bonus;
        }
    }

    public void solve() {
        Scanner input = new Scanner(System.in);

        int s = input.nextInt(), n = input.nextInt();

        Dragon[] d = new Dragon[n];
        for (int i = 0; i < n; i++) {
            int xi = input.nextInt(), yi = input.nextInt();
            d[i] = new Dragon(xi, yi);
        }
        Arrays.sort(d);
        boolean ok = true;
        for(int i = 0; i < n; i++) {
            if(s < d[i].life) {
                ok = false;
                break;
            } else {
                s += d[i].bonus;
            }
        }
        if(ok) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        input.close();
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {
    class Dragon implements Comparable<Dragon> {
        int life, bonus;

        public Dragon(int life, int bonus) {
            this.life = life;
            this.bonus = bonus;
        }

        @Override
        public int compareTo(Dragon o) {
            if (life != o.life) {
                return o.life - bonus;
            }
            return o.bonus - bonus;
        }
    }

    public void solve() {
        Scanner input = new Scanner(System.in);

        int s = input.nextInt(), n = input.nextInt();

        Dragon[] d = new Dragon[n];
        for (int i = 0; i < n; i++) {
            int xi = input.nextInt(), yi = input.nextInt();
            d[i] = new Dragon(xi, yi);
        }
        Arrays.sort(d);
        boolean ok = true;
        for(int i = 0; i < n; i++) {
            if(s < d[i].life) {
                ok = false;
                break;
            } else {
                s += d[i].bonus;
            }
        }
        if(ok) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        input.close();
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}


import java.util.*;

public class Dragons implements Comparable<Dragons>
{
    private int strength;
    private int bonus;

    public Dragons(int inputstrength, int inputbonus)
    {
        strength = inputstrength;
        bonus = inputbonus;
    }

    public int compareTo(Dragons other)
    {
        return this.strength - other.strength;
    }

    public static void main(String[] args)
    {
        // Set up scanner
        Scanner sc = new Scanner(System.in);
        // System.out.println("Input s");
        int s = sc.nextInt();
        // System.out.println("Input n");
        int n = sc.nextInt();
        ArrayList<Dragons> a = new ArrayList<Dragons>();

        for (int i=1; i<=n; i++)
        {
            // System.out.println("Strength of dragon " + i);
            int st = sc.nextInt();
            // System.out.println("Bonus for dragon " + i);
            int bonus = sc.nextInt();
            a.add(new Dragons(st, bonus));
        }

        Collections.sort(a);
        for (Dragons dr: a)
        {
            if (dr.strength >= s)
            {
                System.out.println("NO");
                return;
            }
            else
            {
                s = s + dr.bonus;
            }
        }
        System.out.println("YES");
    }
}


import java.io.*;
import java.util.Scanner;

public class AProblem {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{

		Scanner sc = new Scanner(System.in);

		boolean won = true;
		int s = sc.nextInt();
		int n = sc.nextInt();

		for(int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			if(x >= s)
				won = false;
			else
				s += y;

		}

		System.out.println(won ? "YES" : "NO");

	}

}


import java.io.*;
import java.util.Scanner;

public class AProblem {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{

		Scanner sc = new Scanner(System.in);
//		Scanner sc = new Scanner(new FileReader("test.txt"));

		boolean won = true;
		int s = sc.nextInt();
		int n = sc.nextInt();

		for(int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			if(x > s)
				won = false;
			else
				s += y;

		}

		System.out.println(won ? "YES" : "NO");

	}

}


import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class AProblem {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{

		Scanner sc = new Scanner(System.in);
//		Scanner sc = new Scanner(new FileReader("test.txt"));

		boolean won = true;
		int s = sc.nextInt();
		int n = sc.nextInt();

		ArrayList<Dragon> al = new ArrayList<Dragon>();

		for(int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			al.add(new Dragon(x, y));

		}

		Collections.sort(al);

		for(int i = 0; i < al.size(); i++) {
			if(al.get(i).x >= s)
				won = false;
			else
				s += al.get(i).y;
		}

		System.out.println(won ? "YES" : "NO");

	}

}

class Dragon implements Comparable<Dragon>{

	int x;
	int y;

	public Dragon(int x, int y ) {

		this.x = x;
		this.y = y;
	}

	@Override
	public int compareTo(Dragon arg0) {
		return this.x - arg0.x;
	}

}


import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class AProblem {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{

		Scanner sc = new Scanner(System.in);
//		Scanner sc = new Scanner(new FileReader("test.txt"));

		boolean won = true;
		int s = sc.nextInt();
		int n = sc.nextInt();

		ArrayList<Dragon> al = new ArrayList<Dragon>();

		for(int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			al.add(new Dragon(x, y));

		}

		Collections.sort(al);

		for(int i = 0; i < al.size(); i++) {
			if(al.get(i).x > s)
				won = false;
			else
				s += al.get(i).y;
		}

		System.out.println(won ? "YES" : "NO");

	}

}

class Dragon implements Comparable<Dragon>{

	int x;
	int y;

	public Dragon(int x, int y ) {

		this.x = x;
		this.y = y;
	}

	@Override
	public int compareTo(Dragon arg0) {
		return this.x - arg0.x;
	}

}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.*;
import java.util.*;

/**
 *
 * @author N-AssassiN
 */
public class Main {

    private static BufferedReader reader;
    private static BufferedWriter out;
    private static StringTokenizer tokenizer;
    //private final static String filename = "filename";

    /**
     * call this method to initialize reader for InputStream and OututStream
     */
    private static void init(InputStream input, OutputStream output) {
        reader = new BufferedReader(new InputStreamReader(input));
        out = new BufferedWriter(new OutputStreamWriter(output));
        //reader = new BufferedReader(new FileReader(filename + ".in"));
        //out = new BufferedWriter(new FileWriter(filename + ".out"));
        tokenizer = new StringTokenizer("");
    }

    /**
     * get next word
     */
    private static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        init(System.in, System.out);
        int s = nextInt();
        //long startTime = System.currentTimeMillis();
        int n = nextInt();
        boolean win = true;
        for (int i = 0; i < n; i++) {
            int x = nextInt();
            int y = nextInt();
            if (s > x) {
                s += y;
            } else {
                win = false;
                break;
            }
        }
        if (win) {
            out.write("YES\n");
        } else {
            out.write("NO\n");
        }
        //long runTime = System.currentTimeMillis() - startTime;
        //out.write(runTime + "\n");
        out.flush();
    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.*;
import java.util.*;

/**
 *
 * @author N-AssassiN
 */
public class Main {

    private static BufferedReader reader;
    private static BufferedWriter out;
    private static StringTokenizer tokenizer;
    //private final static String filename = "filename";

    /**
     * call this method to initialize reader for InputStream and OututStream
     */
    private static void init(InputStream input, OutputStream output) {
        reader = new BufferedReader(new InputStreamReader(input));
        out = new BufferedWriter(new OutputStreamWriter(output));
        //reader = new BufferedReader(new FileReader(filename + ".in"));
        //out = new BufferedWriter(new FileWriter(filename + ".out"));
        tokenizer = new StringTokenizer("");
    }

    /**
     * get next word
     */
    private static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        init(System.in, System.out);
        int s = nextInt();
        //long startTime = System.currentTimeMillis();
        int n = nextInt();
        Integer[][] xy = new Integer[n][2];
        boolean win = true;
        for (int i = 0; i < n; i++) {
            xy[i][0] = nextInt();
            xy[i][1] = nextInt();
        }
        Arrays.sort(xy, new Comparator<Integer[]>() {
            @Override
            public int compare(final Integer[] entry1, final Integer[] entry2) {
                return entry1[0].compareTo(entry2[0]);
            }
        });
        for (int i = 0; i < n; i++) {
            if (s > xy[i][0]) {
                s += xy[i][1];
            } else {
                win = false;
                break;
            }
        }
        if (win) {
            out.write("YES\n");
        } else {
            out.write("NO\n");
        }
        //long runTime = System.currentTimeMillis() - startTime;
        //out.write(runTime + "\n");
        out.flush();
    }
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class CodeForcesPractice {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        solve();

        // TODO code application logic here
    }
    public static void solve() {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        String h;

        int l = s.nextInt();
        Integer [][] kp = new Integer[l][2];
        for (int i = 0; i < l; i++) {
            kp[i][0] = s.nextInt();
            kp[i][1] = s.nextInt();

        }
        Arrays.sort(kp, new Comparator<Integer[]>() {

            @Override
            public int compare(Integer[] int1, Integer[] int2) {
                Integer numOfKeys1 = int1[0];
                Integer numOfKeys2 = int2[0];
                return numOfKeys1.compareTo(numOfKeys2);
            }
        });

        for (int i = 0; i <l; i++) {
            if(kp[i][0]<= n){
                n=n+kp[i][1];
            }else{
                System.out.println("NO");
                System.exit(0);
            }
        }
        System.out.println("YES");
    }
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class CodeForcesPractice {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        solve();

        // TODO code application logic here
    }
    public static void solve() {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        String h;

        int l = s.nextInt();
        Integer [][] kp = new Integer[l][2];
        for (int i = 0; i < l; i++) {
            kp[i][0] = s.nextInt();
            kp[i][1] = s.nextInt();

        }
        Arrays.sort(kp, new Comparator<Integer[]>() {

            @Override
            public int compare(Integer[] int1, Integer[] int2) {
                Integer numOfKeys1 = int1[0];
                Integer numOfKeys2 = int2[0];
                return numOfKeys1.compareTo(numOfKeys2);
            }
        });

        for (int i = 0; i <l; i++) {
            if(kp[i][0]< n){
                n=n+kp[i][1];
            }else{
                System.out.println("NO");
                System.exit(0);
            }
        }
        System.out.println("YES");
    }
}


import java.util.Scanner;
public class Dragons {
	public static void bubble(int[][] ar) {
		int prov1 = 0;
		int prov2 = 0;
		for(int i=0; i<ar.length - 1; i++) {
			for(int j=i+1; j<ar.length; j++) {
				if(ar[i][0] > ar[j][0]) {
					prov1 = ar[i][0];
					prov2 = ar[i][1];
					ar[i][0] = ar[j][0];
					ar[j][0] = prov1;
					ar[i][1] = ar[j][1];
					ar[j][1] = prov2;
				}
			}
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		boolean d = false;
		int[][] ar = new int[sc.nextInt()][2];
		for(int i=0; i<ar.length; i++) {
			for(int j=0; j<ar[i].length; j++) {
				ar[i][j] = sc.nextInt();
			}
		}
		bubble(ar);
		for(int i=0; i<ar.length && !d; i++) {
			if(s > ar[i][0]) s += ar[i][1];
			else d = true;
		}
		if(!d) System.out.println("YES");
		else System.out.println("NO");
	}
}


import java.util.Scanner;
public class Dragons {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int n = sc.nextInt();
		boolean d = false;
		int[][] ar = new int[n][2];
		for(int i=0; i<ar.length; i++) {
			for(int j=0; j<ar[i].length; j++) {
				ar[i][j] = sc.nextInt();
			}
		}
		for(int i=0; i<ar.length && !d; i++) {
			if(s > ar[i][0]) {
				s += ar[i][1];
			}
			else {
				d = true;
			}
		}
		if(!d) System.out.println("YES");
		else System.out.println("NO");
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int s = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());

        int[][] mon = new int[n][2];
        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(br.readLine());
            mon[i][0] = Integer.parseInt(st.nextToken());
            mon[i][1] = Integer.parseInt(st.nextToken());
        }

        boolean ok = check(mon, s);
        if(ok)
            System.out.println("YES");
        else
            System.out.println("NO");
    }

    private static boolean check(int[][] mon, int s) {
        int n = mon.length;
        Loop: for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++)
                if (mon[j][0] < s) {
                    s += mon[j][1];
                    mon[j][0] = Integer.MAX_VALUE;
                    continue Loop;
                }
            return false;
        }
        return true;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int s = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());

        int[][] mon = new int[n][2];
        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(br.readLine());
            mon[i][0] = Integer.parseInt(st.nextToken());
            mon[i][1] = Integer.parseInt(st.nextToken());
        }

        boolean ok = check(mon, s);
        if(ok)
            System.out.println("YES");
        else
            System.out.println("NO");
    }

    private static boolean check(int[][] mon, int s) {
        int n = mon.length;
        Loop: for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++)
                if (mon[j][0] <= s) {
                    s += mon[j][1];
                    mon[j][0] = Integer.MAX_VALUE;
                    continue Loop;
                }
            return false;
        }
        return true;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class CFTest40 {

	static class node implements Comparable{

		int a;
		int b;
		public node(int aa,int bb){
			a=aa;
			b=bb;
		}

		public int compareTo(Object o){
			node n=(node)o;
			if(a<n.a)return -1;
			else if(a==n.a)return 0;
			return 1;
		}
	}
    static BufferedReader br;
    public static void main(String[]args){
        br=new BufferedReader(new InputStreamReader(System.in));
        try{

        	int[]arr=readIntArr();
        	int s=arr[0];
        	int n=arr[1];
        	node[]nd=new node[n];
        	for(int i=0;i<n;i++){
        		arr=readIntArr();
        		node ndd=new node(arr[0],arr[1]);
        		nd[i]=ndd;
        	}
            br.close();
            Arrays.sort(nd);

            boolean bl=true;
            int hv=0;
            boolean[]hvv=new boolean[n];
            while(hv<n){
            	int mx=-1;
            	for(int i=0;i<n;i++){
            		if(!hvv[i]){
            			if((mx==-1||nd[i].b>nd[mx].b)&&s>=nd[i].a){
            				mx=i;
            			}
            		}
            	}
            	if(mx==-1)break;
            	else{
            		hvv[mx]=true;
            		s+=nd[mx].b;
            		hv++;
            	}
            }
            //System.out.println(i);
            if(hv==n)System.out.println("YES");
            else System.out.println("NO");

        }catch(IOException e){
            e.printStackTrace();
        }
    }

    static public String readLine() throws IOException{
        return br.readLine();

    }
    static public long readLong() throws IOException{
        return Long.parseLong(br.readLine());
    }

    static public int readInt() throws IOException{
        return Integer.parseInt(br.readLine());
    }

    static public int[] readIntArr() throws IOException{
        String[]str=br.readLine().split(" ");
        int arr[]=new int[str.length];
        for(int i=0;i<arr.length;i++)arr[i]=Integer.parseInt(str[i]);
        return arr;
    }

    static public double[] readDoubleArr() throws IOException{
        String[]str=br.readLine().split(" ");
        double arr[]=new double[str.length];
        for(int i=0;i<arr.length;i++)arr[i]=Double.parseDouble(str[i]);
        return arr;
    }
    static public long[] readLongArr() throws IOException{
        String[]str=br.readLine().split(" ");
        long arr[]=new long[str.length];
        for(int i=0;i<arr.length;i++)arr[i]=Long.parseLong(str[i]);
        return arr;
    }

    static public double readDouble() throws IOException{
        return Double.parseDouble(br.readLine());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class CFTest40 {

	static class node implements Comparable{

		int a;
		int b;
		public node(int aa,int bb){
			a=aa;
			b=bb;
		}

		public int compareTo(Object o){
			node n=(node)o;
			if(a<n.a)return -1;
			else if(a==n.a)return 0;
			return 1;
		}
	}
    static BufferedReader br;
    public static void main(String[]args){
        br=new BufferedReader(new InputStreamReader(System.in));
        try{

        	int[]arr=readIntArr();
        	int s=arr[0];
        	int n=arr[1];
        	node[]nd=new node[n];
        	for(int i=0;i<n;i++){
        		arr=readIntArr();
        		node ndd=new node(arr[0],arr[1]);
        		nd[i]=ndd;
        	}
            br.close();
            Arrays.sort(nd);

            int i=0;
            boolean bl=true;
            for(;i<n;i++){
            	//System.out.println(nd[i].b);
            	if(s<nd[i].a){
            		bl=false;
            		break;
            	}
            	else{
            		s+=nd[i].b;
            	}
            	//System.out.println(s);
            }
            //System.out.println(i);
            if(bl)System.out.println("YES");
            else System.out.println("NO");

        }catch(IOException e){
            e.printStackTrace();
        }
    }

    static public String readLine() throws IOException{
        return br.readLine();

    }
    static public long readLong() throws IOException{
        return Long.parseLong(br.readLine());
    }

    static public int readInt() throws IOException{
        return Integer.parseInt(br.readLine());
    }

    static public int[] readIntArr() throws IOException{
        String[]str=br.readLine().split(" ");
        int arr[]=new int[str.length];
        for(int i=0;i<arr.length;i++)arr[i]=Integer.parseInt(str[i]);
        return arr;
    }

    static public double[] readDoubleArr() throws IOException{
        String[]str=br.readLine().split(" ");
        double arr[]=new double[str.length];
        for(int i=0;i<arr.length;i++)arr[i]=Double.parseDouble(str[i]);
        return arr;
    }
    static public long[] readLongArr() throws IOException{
        String[]str=br.readLine().split(" ");
        long arr[]=new long[str.length];
        for(int i=0;i<arr.length;i++)arr[i]=Long.parseLong(str[i]);
        return arr;
    }

    static public double readDouble() throws IOException{
        return Double.parseDouble(br.readLine());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class CFTest40 {

	static class node implements Comparable{

		int a;
		int b;
		public node(int aa,int bb){
			a=aa;
			b=bb;
		}

		public int compareTo(Object o){
			node n=(node)o;
			if(a<n.a)return -1;
			else if(a==n.a)return 0;
			return 1;
		}
	}
    static BufferedReader br;
    public static void main(String[]args){
        br=new BufferedReader(new InputStreamReader(System.in));
        try{

        	int[]arr=readIntArr();
        	int s=arr[0];
        	int n=arr[1];
        	node[]nd=new node[n];
        	for(int i=0;i<n;i++){
        		arr=readIntArr();
        		node ndd=new node(arr[0],arr[1]);
        		nd[i]=ndd;
        	}
            br.close();
            Arrays.sort(nd);

            boolean bl=true;
            int hv=0;
            boolean[]hvv=new boolean[n];
            while(hv<n){
            	int mx=-1;
            	for(int i=0;i<n;i++){
            		if(!hvv[i]){
            			if((mx==-1||nd[i].b>nd[mx].b)&&s>nd[i].a){
            				mx=i;
            			}
            		}
            	}
            	if(mx==-1)break;
            	else{
            		hvv[mx]=true;
            		s+=nd[mx].b;
            		hv++;
            	}
            }
            //System.out.println(i);
            if(hv==n)System.out.println("YES");
            else System.out.println("NO");

        }catch(IOException e){
            e.printStackTrace();
        }
    }

    static public String readLine() throws IOException{
        return br.readLine();

    }
    static public long readLong() throws IOException{
        return Long.parseLong(br.readLine());
    }

    static public int readInt() throws IOException{
        return Integer.parseInt(br.readLine());
    }

    static public int[] readIntArr() throws IOException{
        String[]str=br.readLine().split(" ");
        int arr[]=new int[str.length];
        for(int i=0;i<arr.length;i++)arr[i]=Integer.parseInt(str[i]);
        return arr;
    }

    static public double[] readDoubleArr() throws IOException{
        String[]str=br.readLine().split(" ");
        double arr[]=new double[str.length];
        for(int i=0;i<arr.length;i++)arr[i]=Double.parseDouble(str[i]);
        return arr;
    }
    static public long[] readLongArr() throws IOException{
        String[]str=br.readLine().split(" ");
        long arr[]=new long[str.length];
        for(int i=0;i<arr.length;i++)arr[i]=Long.parseLong(str[i]);
        return arr;
    }

    static public double readDouble() throws IOException{
        return Double.parseDouble(br.readLine());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A {
	static BufferedReader in;
	static StringTokenizer st;
	static PrintWriter out;

	static String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	static int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}
	static long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}
	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		st = new StringTokenizer(in.readLine());
		out = new PrintWriter(new OutputStreamWriter(System.out));
		int s = nextInt();
		int n = nextInt();
		boolean win = true;
		for (int i = 0; i < n; i++) {
			int x = nextInt();
			int y = nextInt();
			if(s > x){
				s = s  + y;
			}else{
				win = false;
			}
		}
		if(win){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {
	static BufferedReader in;
	static StringTokenizer st;
	static PrintWriter out;

	static String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	static int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}
	static long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}
	static class Point implements Comparable<Point>{
		int x, y;
		public int compareTo(Point arg0) {
			if(this.x>arg0.x){
				return 1;
			}
			return 0;
		}
		public Point(int a, int b){
			x = a; y = b;
		}
	}
	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		st = new StringTokenizer(in.readLine());
		out = new PrintWriter(new OutputStreamWriter(System.out));
		int s = nextInt();
		int n = nextInt();
		boolean win = true;
		Point p[] = new Point[n];
		for (int i = 0; i < n; i++) {
			int x = nextInt();
			int y = nextInt();
			p[i]  = new Point(x,y);
		}
		Arrays.sort(p);
		for (int i = 0; i < p.length; i++) {
//			System.out.println(p[i].x+" "+p[i].y);
			if(s > p[i].x){
				s +=p[i].y;
			}else{
				win = false;
			}
		}
		if(win){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A {
	static BufferedReader in;
	static StringTokenizer st;
	static PrintWriter out;

	static String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	static int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}
	static long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}
	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		st = new StringTokenizer(in.readLine());
		out = new PrintWriter(new OutputStreamWriter(System.out));
		int s = nextInt();
		int n = nextInt();
		boolean win = true;
		for (int i = 0; i < n; i++) {
			int x = nextInt();
			int y = nextInt();
			if(s >= x){
				s =s - x + y;
			}else{
				win = false;
			}
		}
		if(win){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int s,n;
    cin>>s>>n;
    pair<int,int>xy[n];
    for(int i=0;i<n;i++)cin>>xy[i].first>>xy[i].second;
    sort(xy,xy+n);
    int counter=0;
    if(s>xy[0].first){
        for(int i=0;i<n;i++){
            if(s>xy[i].first){
                counter++;
                s=s+xy[i].second;
            }
            else{
                cout<<"NO";
                break;
            }
        }
    }
    else cout<<"NO";
    if(counter==n)cout<<"YES";
    return 0;

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main()
{
	int s, n;
	scanf("%d %d", &s, &n);
	map<int, int> dragons;
	for(int i=0; i<n; i++)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		dragons[a] += b;

	}
	for(auto p : dragons)
	{
		if(s <= p.first)
		{
			printf("NO\n");
			return 0;
		}
		s += p.second;
	}

	printf("YES\n");

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int s, n;
	scanf("%d %d", &s, &n);
	vector< pair<int, int> > dragons;
	for(int i=0; i<n; i++)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		dragons.push_back( make_pair(a, b));
	}
	sort(dragons.begin(), dragons.end());
	for(int i=0; i< n; i++)
	{
		if(s <= dragons[i].first)
		{
			//we die
			printf("NO\n");
			return 0;
		}
		s = s + dragons[i].second;
	}
	printf("YES\n");

	return 0;
}


#include <iostream>
using namespace std;
#include<algorithm>
int main()
{
  int ks,dcount,a,b,i=0;

  cin>>ks;
  cin>>dcount;
  int ds[dcount],gain[dcount];
  for(i=0;i<dcount;i++)
  {
      cin>>ds[i];
      cin>>gain[i];
  }
  int temp=0;
  for(i=0;i<dcount-1;i++)
  {
      for(int j=0;j<dcount-i-1;j++)
      {
          if(ds[j]>ds[j+1])
          {
              temp=ds[j];
              ds[j]=ds[j+1];
              ds[j+1]=temp;

              temp=gain[j];
              gain[j]=gain[j+1];
              gain[j+1]=temp;
          }
      }
  }
  i=0;
  while(i<dcount)
  {
      if(ds[i]<=ks)
      {
      ks+=gain[i];
      i++;
      }
      else
      break;
  }
  if(i==dcount)
  cout<<"YES";
  else
  cout<<"NO";
	return 0;
}


#include <iostream>
using namespace std;
#include<algorithm>
int main()
{
  int ks,dcount,a,b,i=0;

  cin>>ks;
  cin>>dcount;
  int ds[dcount],gain[dcount];
  for(i=0;i<dcount;i++)
  {
      cin>>ds[i];
      cin>>gain[i];
  }
  int temp=0;
  for(i=0;i<dcount-1;i++)
  {
      for(int j=0;j<dcount-i-1;j++)
      {
          if(ds[j]>ds[j+1])
          {
              temp=ds[j];
              ds[j]=ds[j+1];
              ds[j+1]=temp;

              temp=gain[j];
              gain[j]=gain[j+1];
              gain[j+1]=temp;
          }
      }
  }
  i=0;
  while(i<dcount)
  {
      if(ds[i]<ks)
      {
      ks+=gain[i];
      i++;
      }
      else
      break;
  }
  if(i==dcount)
  cout<<"YES";
  else
  cout<<"NO";
	return 0;
}


    #include <stdio.h>
    #include<string.h>
    int main(void) {
    	int s,n;
    	scanf("%d %d",&s,&n);
    	int x[n],y[n],flag=1;
    	for(int i=0;i<n;i++)scanf("%d %d",&x[i],&y[i]);
    	for(int i=0;i<n;i++){
    	    int minx=x[i],stx=i,maxy=y[i],sty=i;
    	    for(int j=i+1;j<n;j++){
    	        if(minx>x[j]){
    	            minx=x[j];
    	            stx=j;
    	        }
    	        if(maxy<y[j]){
    	            maxy=y[j];
    	            sty=j;
    	        }
    	    }
    	    int temp=minx;
    	    x[stx]=x[i];
    	    x[i]=temp;
    	    temp=maxy;
    	    y[sty]=y[i];
    	    y[i]=maxy;
    	}
    	for(int i=0;i<n;i++){
    	     if(s>x[i]){
    	        s+=y[i];
    	    }else{
    	        printf("NO");
    	        flag=0;
    	        break;
    	    }
    	}
    	if(flag)printf("YES");
    	return 0;
    }


    #include <stdio.h>
    #include<string.h>
    int main(void) {
    	int s,n;
    	scanf("%d %d",&s,&n);
    	int x[n],y[n],flag=1;
    	for(int i=0;i<n;i++){
    	    scanf("%d %d",&x[i],&y[i]);
    	     if(s>x[i]){
    	        s+=y[i];
    	    }else{
    	        printf("NO");
    	        flag=0;
    	        break;
    	    }
    	}
    	if(flag)printf("YES");
    	return 0;
    }

s


    #include <stdio.h>
    #include<string.h>
    int main(void) {
    	int s,n;
    	scanf("%d %d",&s,&n);
    	int x[n],y[n],flag=1;
    	for(int i=0;i<n;i++)scanf("%d",&x[i]);
    	for(int i=0;i<n;i++)scanf("%d",&y[i]);
    	for(int i=0;i<n;i++){
    	    if(s>x[i]){
    	        s+=y[i];
    	    }else{
    	        printf("NO");
    	        flag=0;
    	        break;
    	    }
    	}
    	if(flag)printf("YES");
    	return 0;
    }


    #include <stdio.h>
    #include<string.h>
    int main(void) {
    	int s,n;
    	scanf("%d %d",&s,&n);
    	int x[n],y[n],flag=1;
    	for(int i=0;i<n;i++){
    	    scanf("%d %d",&x[i],&y[i]);
    	     if(s>x[i]){
    	        s+=y[i];
    	    }else{
    	        printf("NO");
    	        flag=0;
    	        break;
    	    }
    	}
    	if(flag)printf("YES");
    	return 0;
    }


    #include <stdio.h>
    #include<string.h>
    int main(void) {
    	int s,n;
    	scanf("%d %d",&s,&n);
    	int x[n],y[n],flag=1;
    	for(int i=0;i<n;i++)scanf("%d %d",&x[i],&y[i]);
    	for(int i=0;i<n;i++){
    	    int minx=x[i],stx=i;
    	    for(int j=i+1;j<n;j++){
    	        if(minx>x[j]){
    	            minx=x[j];
    	            stx=j;
    	        }
    	    }
    	    int temp=minx;
    	    x[stx]=x[i];
    	    x[i]=temp;
    	    temp=y[stx];
    	    y[stx]=y[i];
    	    y[i]=temp;
    	}
    	for(int i=0;i<n;i++){
    	    //printf("%d %d\n",x[i],y[i]);
    	    if(s>x[i]){
    	        s+=y[i];
    	    }else{
    	        printf("NO");
    	        flag=0;
    	        break;
    	    }
    	}
    	if(flag)printf("YES");
    	return 0;
    }


#include<stdio.h>
using namespace std;
int main()
{

	int s,n,i,j;
	int temp1,temp2;
	int a[1001],b[1001];
	int sum;
	sum=0;
	scanf("%d %d",&s,&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
	}

	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(a[j]<a[i])
			{
				temp1=a[j];
				temp2=b[j];
				a[j]=a[i];
				b[j]=b[i];
				a[i]=temp1;
				b[i]=temp2;
			}
		}
	}

	for(i=0;i<n;i++)
	{
		if(s>a[i])
		{
			s=s+b[i];
			sum++;
		}
	}

	if(sum==n)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}

    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int s,n,a[1000],b[1000],t=0;
    cin>>s>>n;
    int i;
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(i=0;i<n;i++)
    {
        if(s>a[i])
        {
            s+=b[i];
            t++;
        }
    }
     if(t==n)
        cout<<"YES";
     else
        cout<<"NO";

}


#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int s, n;
	pair <int, int> v[1000];
	cin >> s >> n;
	for (int i = 0; i < n; ++i)
		cin >> v[i].first >> v[i].second;
	sort(v, v + n);
	for (int i = 0; i < n; ++i)
		if (s < v[i].first) {
			cout << "NO";
			return 0;
		}
		else
			s += v[i].second;
	cout << "YES";
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int s, n;
	pair <int, int> v[1000];
	cin >> s >> n;
	for (int i = 0; i < n; ++i)
		cin >> v[i].first >> v[i].second;
	sort(v, v + n);
	for (int i = 0; i < n; ++i)
		if (s <= v[i].first) {
			cout << "NO";
			return 0;
		}
		else
			s += v[i].second;
	cout << "YES";
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <set>
#include <math.h>
using namespace std;

#define pii pair<int, int>

int compare(pii a, pii b) {
    if (a.first != b.first)
        return a.first - b.first;
    return b.second - a.second;
}

void quicksort(pii arr[], int l, int r) {
    pii pivot = arr[l + (r - l) / 2];
    int i = l, j = r;
    while(i <= j) {
        while(compare(arr[i], pivot) < 0) i++;
        while(compare(arr[j], pivot) > 0) j--;
        if (i <= j) {
            swap(arr[i], arr[j]);
            i++;
            j--;
        }
    }
    if (i < r)
        quicksort(arr, i, r);
    if (l < j)
        quicksort(arr, l, j);
}

int main()
{
    int s, n;
    scanf("%d%d", &s, &n);
    pii p[1005];
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &p[i].first, &p[i].second);
    }
    quicksort(p, 0, n - 1);
    bool ok = true;
    for (int i = 0; i < n; i++) {
        if (s <= p[i].first) {
            ok = false;
            break;
        }
        s += p[i].second;
    }
    printf("%s", ok ? "YES" : "NO");
}


#include<bits/stdc++.h>
#define mem(array,num) memset(array,num,sizeof(array))
using namespace std;
int main()
{
    long int x,c,i,j,s,n,array,num;
    pair<int, int>a[1000];
    while(cin>>s>>n)
    {
        c=1;
        for(i=0;i<n;i++)
        {
            cin>>a[i].first>>a[i].second;

        }
        sort(a,a+n);
         for(i=0;i<n;i++)
         {
             if(s<=a[i].first)
             {
                 c=0;
                 break;
             }
             else
             {
                 s=s+a[i].second;
             }
         }
         if(c==0)
            cout<<"NO\n";
         else
            cout<<"YES\n";
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main()
{
       int s,n,i;
       int f=0;
       cin>>s>>n;
       int ds[n],b[n];
       for(i=0;i<n;i++)
       {
              cin>>ds[i]>>b[i];
       }
       vector < pair< int,int> >v;
       for (int i=0; i<n; i++)
       {
        v.push_back(make_pair(ds[i],b[i]) );
       }
        sort(v.begin(),v.end());
        for(i=0;i<n;i++)
        {
             if(s>v[i].first)
             s=s+v[i].second;
             else
             {
                    cout<<"NO";
                    f=1;
                    break;
             }

        }
        if(f==0)
        cout<<"YES";
        return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main()
{
       int s,n,i;
       int f=0;
       cin>>s>>n;
       int ds[n],b[n];
       for(i=0;i<n;i++)
       {
              cin>>ds[i]>>b[i];
       }
       vector < pair< int,int> >v;
       for (int i=0; i<n; i++)
       {
        v.push_back(make_pair(ds[i],b[i]) );
       }
        sort(v.begin(),v.end());
        for(i=0;i<n;i++)
        {
             if(s>v[i].first)
             s=s+v[i].second;
             else
             {
                    cout<<"NO";
                    f=1;
             }

        }
        if(f==0)
        cout<<"YES";
        return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main()
{
       int s,n,ds,b,i;
       int f=0;
       cin>>s>>n;
       for(i=0;i<n;i++)
       {
              cin>>ds>>b;
              if(s>ds)
              {
                     s=s+b;
              }
              else
              {
                      f=1;
                     cout<<"NO";

              }
       }
       if(f==0)
       cout<<"YES";
     return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int s, n, a, b;
vector <pair <int, int >> v;
int main() {
    cin >> s >> n;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
        if(s <= v[i].first){
            cout << "NO";
            return 0;
        } else {
            s += v[i].second;
        }
    }
    cout << "YES";
}


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

int main() {
	// your code goes here
	long long s,n;
	cin>>s>>n;
	vector<pair<long long ,long long >> p;
	for(long long i=0;i<n;i++)
	{
		long long x,y;
		cin>>x>>y;
		p.push_back(make_pair(x,y));
	}
	sort(p.begin(),p.end());
	for(long long i=0;i<n;i++)
	{
		if(p[i].first<=s)
		{
			s=s+p[i].second;
		}
		else
		{
			cout<<"NO\n";
			return 0;
		}
	}
	cout<<"YES\n";
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long s,n;
	cin>>s>>n;
	for(long long i=0;i<n;i++)
	{
		long long x,y;
		cin>>x>>y;
		if(x<=s)
		{
			s=s+y;
		}
		else
		{
			cout<<"NO\n";
			return 0;
		}
	}
	cout<<"YES\n";
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int s,n,i=0;
	cin>>s>>n;
	int a[n][2];
	for(int i=0;i<n;i++)
		cin>>a[i][0]>>a[i][1];
	while(i<n)
	{
		if(s>a[i][0] && a[i][0]>0)
		{
			s+=a[i][1];
			a[i][0]=0;
			i=0;
		}
		else
			i++;
	}
	for(int i=0;i<n;i++)
	{
		if(a[i][0]!=0)
		{
			cout<<"NO";
			return(0);
		}
	}
	cout<<"YES";
	return(0);
}


#include<iostream>
using namespace std;
int main()
{
	int s,n,count=1,a,b;
	cin>>s>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(s>a)
		{
			s+=b;
		}
		else
		{
			cout<<"NO";
			return(0);
		}
	}
	cout<<"YES";
	return(0);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s,i,x[10000],y[10000];
    cin>>s>>n;//S is k's strength
    for(i=0;i<n;i++)
    {
        cin>>x[i];
        cin>>y[i];
    }
    for(i=0;i<n;i++)
    {
        if(x[i]<s)
        {
            s+=y[i];
        }
        else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

    return 0;
}


#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int s,n,i,x,y;
    bool j=1;
    vector<pair<int , int> >a;
    cin>>s>>n;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        a.push_back(make_pair(x,y));
    }
    sort(a.begin(),a.end());
    for(i=0;i<n;i++)
    {
        if(s>a[i].first)
        {
            s+=a[i].second;
        }
        else
        {
            j=0;
            break;
        }
    }
    if(j)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int s,n,i,j,x,y;
    vector<pair<int , int> >a;
    cin>>s>>n;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        a.push_back(make_pair(x,y));
    }
    sort(a.begin(),a.end());
    for(i=0;i<n;i++)
    {
        if(s>a[i].first)
        {
            s+=a[i].second;
        }
        else
        {
            j++;
            break;
        }
    }
    if(j==1)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
pair <int , int> ar[1000];
int main()
{

 int s , n ;
  cin >> s  >> n;
  for (int i = 0; i < n ; i++)
    cin >> ar[i].first >> ar[i].second;

    sort(ar,ar+n);

    for (int i = 0; i < n ; i++)
    {
        if (ar[i].first < s)
        {
            s+=ar[i].second;
        }
        else
        {
            cout << "NO";
            return 0 ;
        }
    }
    cout << "YES";
}


#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	vector<pair<int ,int> > pa;
	int s,n;
	cin>>s>>n;
	bool can=true;
 	 for(int i=0;i<n;i++){
		 int x,y;
		 cin>>x>>y;
		  pa.push_back(make_pair(x,y));
	 }
	 sort(pa.begin(),pa.end());
	 for(int i=0;i<n;i++){
		 if(s>pa[i].first){
			 s+=pa[i].second;
		 }

		 else{
			 can=0;
			 break;
		 }
	 		  }

if(can)cout<<"YES";else cout<<"NO";

 	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int s, n, a, b;
vector <pair <int, int >> v;
int main()
{
    cin>>s>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
    {
        if(s<=v[i].first)
        {
            cout<<"NO";
            return 0;
        }
        else
        {
            s += v[i].second;
        }
    }
    cout << "YES";
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s,a,b,j,i,sum=0,count=0,dr[100000],dra[100000];
    scanf("%d%d",&s,&n);
    sum=sum+s;
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&a,&b);
        dr[i]=a;
        dra[i]=b;}
    for(i=0;i<n-1;i++)
    {
        for(j=0;j<n-i-1;j++)
        {
            if(dr[j]>dr[j+1]){
                swap(dr[j],dr[j+1]);
                swap(dra[j],dra[j+1]);}
        }
    }
    for(i=0;i<n;i++){

        if(s>dr[i])
        {
            count++;
        }
        s=s+dra[i];
    }
    if(count==n)printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s,a,b,j,i,sum=0,count=0,dr[100000],dra[100000];
    scanf("%d%d",&s,&n);
    sum=sum+s;
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&a,&b);
        dr[i]=a;
        dra[i]=b;}
    for(i=0;i<n;i++)
    {
        for(j=0;j<=n-i-1;j++)
        {
            if(dr[j]>=dr[j+1])
                swap(dr[j],dr[j+1]);
                swap(dra[j],dra[j+1]);
        }
    }
    for(i=1;i<n;i++){
        if(sum>dr[i])
        {
            count++;
        }
        sum=sum+dra[i];
    }
    if(count==n-1)printf("YES\n");
    else printf("NO\n");

    return 0;
}


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

int main()
{
    int s=0,n,count=0;
    cin>>s>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]<s)
        {
            count++;
        }
        s+=b[i];

    }

    if(count==n)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

    return 0;
}


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

int main()
{
    int s=0,n,count=0;
    cin>>s>>n;
    int a[n],b[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        cin>>b[i];
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n-i-1; j++)
        {
            if(a[j]>a[j+1])
            {
                swap(a[j],a[j+1]);
                swap(b[j],b[j+1]);
            }
        }
    }

    for(int i=0; i<n; i++)
    {
        if(a[i]<s)
        {
            count++;
        }
        s+=b[i];

    }

    if(count==n)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

    return 0;
}


#include <algorithm>
#include <iostream>

using namespace std;

struct cmp {
    int x, y;
}array[1005];

bool tmp ( cmp a, cmp b ) {
    return a.x < b.x;
}

int main ( ) {
    int s, n, x, y, ans;
    ans = 0;
    cin >> s >> n;
    for ( int i = 0; i < n; ++i )
        cin >> array[i].x >> array[i].y;
    sort ( array, array + n, tmp );

    for ( int i = 0; i < n; ++i ) {
        if ( s > array[i].x ) {
            s += array[i].y;
            ans++;
        }
    }

    if ( ans == n ) cout << "YES" << endl;
    else cout << "NO" << endl;
}


#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 1010;
struct Dragon{
    int x,y;
    bool operator < (const Dragon &rhs) const{
        return x < rhs.x;
    }
}dragon[1010];

int main(){
    int s,n;
    scanf("%d%d",&s,&n);
    for(int i = 0;i < n;i++){
        scanf("%d%d",&dragon[i].x,&dragon[i].y);
    }
    sort(dragon,dragon+n);//默认排序为从小到大
    bool flag = 1;
    for(int i = 0;i < n;i++){
        if(s <= dragon[i].x){
            flag = 0;
            break;
        }else{
            s += dragon[i].y;
        }
    }
    if(flag)    puts("YES");
    else        puts("NO");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct EvilDragon
{
    int power, reward;
    EvilDragon(int p, int r)
    {
        power = p;
        reward = r;
    }

    bool operator<(const EvilDragon &a) const
    {
        return power < a.power;
    }
};
typedef vector<EvilDragon> DragonList;
DragonList kiritoEnmeies;

int main()
{
    int s, n;
    cin >> s >> n;
    bool isLose = false;
    for (int i = 0; i < n; i++)
    {
        int xi, yi;
        cin >> xi >> yi;
        EvilDragon d(xi, yi);
        kiritoEnmeies.push_back(d);
    }

    sort(kiritoEnmeies.begin(), kiritoEnmeies.end());

    bool canDefeat = true;
    for (int i = 0; i < n; i++)
    {
        EvilDragon ed = kiritoEnmeies[i];
        int strgh = ed.power;

        if (s <= strgh)
        {
            canDefeat = false;
            break;
        }
        else
        {
            s += ed.reward;
        }
    }

    if (!canDefeat)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }

    return 0;
}


#include<bits/stdc++.h>
#define mem(array,num) memset(array,num,sizeof(array))
using namespace std;
int main()
{
    long int x,c,i,j,s,n,array,num;
    pair<int, int>a[1000];
    while(cin>>s>>n)
    {
        c=1;
        for(i=0;i<n;i++)
        {
            cin>>a[i].first>>a[i].second;

        }
        sort(a,a+n);
         for(i=0;i<n;i++)
         {
             if(s<=a[i].first)
             {
                 c=0;
                 break;
             }
             else
             {
                 s=s+a[i].second;
             }
         }
         if(c==0)
            cout<<"NO\n";
         else
            cout<<"YES\n";
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    long int s,n,c=0;
    cin>>s>>n;
    long int d[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>d[i]>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(d[i]>d[j])
            {
                d[i]=d[i]+d[j];
                d[j]=d[i]-d[j];
                d[i]=d[i]-d[j];
                b[i]=b[i]+b[j];
                b[j]=b[i]-b[j];
                b[i]=b[i]-b[j];
            }
        }
    }
    for(int i=0;i<n;i++)
    {
       if(s>d[i])
       {
           s=s+b[i];
           c++;
       }
       else
       {
           cout<<"NO";
       }
    }
    if(n==c)
    {
        cout<<"YES";
    }
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
    long int s,n,c=0;
    cin>>s>>n;
    long int d[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>d[i]>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(d[i]>d[j])
            {
                d[i]=d[i]+d[j];
                d[j]=d[i]-d[j];
                d[i]=d[i]-d[j];
                b[i]=b[i]+b[j];
                b[j]=b[i]-b[j];
                b[i]=b[i]-b[j];
            }
        }
    }
    for(int i=0;i<n;i++)
    {
       if(s>d[i])
       {
           s=s+b[i];
           c++;
       }
       else
       {
           cout<<"NO";
           break;
       }
    }
    if(n==c)
    {
        cout<<"YES";
    }
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
    long int s,n,c=0;
    cin>>s>>n;
    int d,b;
    for(int i=0;i<n;i++)
    {
        cin>>d>>b;
        if(s>d)
        {
            s=s+b;
            c++;
        }
        else
        {
            cout<<"NO";
            break;
        }
    }
    if(n==c)
    {
        cout<<"YES";
    }
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <string>

using namespace std;

int kirto_S, n, dragons[1001][2];
int strenght[2], gecici[2], c=0, a = 0;

int main() {

    cin >> kirto_S >> n;

    while (c < n)
    {
        cin >> dragons[c][0] >> dragons[c][1];
        a = c;
        while (a > 0) {
            if (dragons[a][0] < dragons[a-1][0])
            {
                gecici[0] = dragons[a-1][0];
                gecici[1] = dragons[a-1][1];

                dragons[a-1][0] = dragons[a][0];
                dragons[a-1][1] = dragons[a][1];

                dragons[a][0] = gecici[0];
                dragons[a][1] = gecici[1];
            }
            a--;
        }
        c++;
    }

    c = 0;
    while (c < n) {
        if(kirto_S > dragons[c][0])
        {
            kirto_S += dragons[c][1];
        }
        else{
            cout << "NO";
            return 0;
        }
        c++;
    }
    cout << "YES";
}


#include<bits/stdc++.h>
using namespace std;
void swap(int a,int b)
{
      int temp=a;
      a=b;
      b=a;
}
int main()
{
      int s,n;
      cin>>s>>n;
      int a[n],b[n];
      for(int i=0;i<n;i++)
            cin>>a[i]>>b[i];
      for(int i=0;i<n;i++)
      {
            int minindex=i;
            for(int j=i+1;j<n;j++)
            {
                  if(a[minindex]>a[j])
                        minindex=j;
            }
            int temp=a[minindex];
            a[minindex]=a[i];
            a[i]=temp;
            int t=b[minindex];
            b[minindex]=b[i];
            b[i]=t;
      }
      for(int i=0;i<n;i++)
      {
            if(a[i]>=s)
            {
                  cout<<"NO";
                  return 0;
            }
            s+=b[i];
      }
      cout<<"YES";
}


#include<cstdio>
#include<string>
using namespace std;
int main(){
     int s,n;
     cin>>s>>n;
     int x,y;
     for(int i=0;i<n;i++){
          cin>>x>>y;
          if(s>x){
            s=s+y;
            cout<<"YES";
            return 0;
          }
          cout<<"NO";
     }
}


#include<cstdio>
#include<string>
using namespace std;
int main(){
     int s,n;
     cin>>s>>n;
     int x,y;
     for(int i=0;i<n;i++){
          cin>>x>>y;
          if(s>x){
            s=s+y;
            cout<<"YES";
            return 0;
          }
     }
      cout<<"NO";
}


#include<iostream>
using namespace std;
int main()
{
    long long int p,s,n,c=0,m[100000],bns[100000];
    cin>>s>>n;
    for(p=0;p<n;p++) cin>>m[p]>>bns[p];
    for(p=0;p<n;p++)
    {
        if(s>m[p])
        {
            s+=bns[p]; c++;
        }
        else break;
    }
    if(c!=n) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int p,q,s,n,c=0,m[100000],bns[100000];
    cin>>s>>n;
    for(p=0;p<n;p++) cin>>m[p]>>bns[p];
    for(p=0;p<n-1;p++)
    {
        for(q=p+1;q<n;q++)
        {
            if(m[p]>m[q])
            {
                int temp=m[p]; m[p]=m[q]; m[q]=temp;
                temp=bns[p]; bns[p]=bns[q]; bns[q]=temp;
            }
        }
    }
    for(p=0;p<n;p++)
    {
        if(s>m[p])
        {
            c++;
            s+=bns[p];
        }
        else break;
    }
    if(c!=n) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


#include <iostream>
#include <vector>
using namespace std;

#define pb push_back
#define mp make_pair
bool isDefeated(int s ,vector<pair<int,int>>&arr1){
	bool status=false;
	for(size_t i=0;i<arr1.size();i++){
		if(s>arr1[i].first){
			s=s-arr1[i].first;
			s=s+arr1[i].second;
			status=true;
		}
	}
	return status;
}

int main(){
	int s , n;
	cin >> s >> n ;
	vector<pair<int,int>> arr1;
	while(n--){
		int x, y;
		cin >> x >>y;
		arr1.pb(mp(x,y));
	}

	if(isDefeated(s,arr1)){
		cout <<"YES"<<"\n";
	}
	else{
		cout <<"NO"<<"\n";
	}

	return 0;

}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define pb push_back
#define mp make_pair
/*
bool isDefeated(int s ,vector<pair<int,int>>&arr1){
	bool status=false;
	for(size_t i=0;i<arr1.size();i++){
		if(s>arr1[i].first){
			s=s-arr1[i].first;
			s=s+arr1[i].second;
			status=true;
		}
	}
	return status;
}
*/
/*
if krito fights a dragon whose strength is less than kritos
then krito does not lose anything
and gains a non negative strength
so for each step choose some dragon whose strength is less than
Kritos current strength
and fight it.
on eaach step choose a suitbale dragon to fight either by searching
through all dragons or sorting the draagons by strength
in non-descending order in advance
*/

bool isDefeated(int s ,vector<pair<int,int>>&arr1){
	int c;
	sort(arr1.begin(),arr1.end());
	for(size_t i=0;i<arr1.size();i++){
		if(s<=arr1[i].first){
			c=0;
			break;
		}
		else{
			s=s+arr1[i].second;
		}
	}
	if(c==0){
		return false;
	}
	else{
		return true;
	}
}

int main(){
	int s , n;
	cin >> s >> n ;
	vector<pair<int,int>> arr1;
	while(n--){
		int x, y;
		cin >> x >>y;
		arr1.pb(mp(x,y));
	}

	if(isDefeated(s,arr1)){
		cout <<"YES"<<"\n";
	}
	else{
		cout <<"NO"<<"\n";
	}

return 0;

}


#include<iostream>
using namespace std;
int main()
{
	int s,n,i;
	cin>>s>>n;
	int sum1=s;
	int *arr=new int[n];
	int *brr=new int[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i]>>brr[i];
		if(s>=arr[i])
		{
			sum1+=brr[i];
		}
	}
	sort(arr,arr+n);
	for(i=0;i<n;i++)
	{
		if(s<arr[i])
		{
			if(sum1<arr[i])
			{
				cout<<"NO";
				return 0;
			}
			else
				sum1+=brr[i];
		}
	}
	cout<<"YES";
}


#include<iostream>
using namespace std;
int main()
{
	int s,n,i;
	cin>>s>>n;
	int sum1=s;
	int *arr=new int[n];
	int *brr=new int[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i]>>brr[i];
		if(s>=arr[i])
		{
			sum1+=brr[i];
		}
	}
	sort(arr,arr+n);
	for(i=0;i<n;i++)
	{
		if(s<arr[i])
		{
			if(sum1<arr[i])
			{
				cout<<"NO";
				return 0;
			}
			else
				sum1+=arr[i];
		}
	}
	cout<<"YES";
}


#include<iostream>
using namespace std;
int main()
{
	int s,n,i;
	cin>>s>>n;
	int sum1=s;
	int *arr=new int[n];
	int *brr=new int[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i]>>brr[i];
		if(s>arr[i])
		{
			sum1+=brr[i];
		}
	}
	sort(arr,arr+n);
	for(i=0;i<n;i++)
	{
		if(s<=arr[i])
		{
			if(sum1<=arr[i])
			{
				cout<<"NO";
				return 0;
			}
			else
				sum1+=brr[i];
		}
	}
	cout<<"YES";
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <iterator>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
 vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#ifdef TESTING
#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG
#define VALUE(x)
#define debug(...)
#endif

#define IOS ios_base::sync_with_stdio(false);\
        cin.tie(0);\
        cout.tie(0);
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a))
#define FOREACH(a, b) for (auto&(a) : (b))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define tc(t) while (t--)
int main()
{
	IOS
	int s,n,a,b;
	int sum1;
	multimap< int,int > m;
	multimap< int,int > :: iterator it;
	pair< int,int > x;
	cin>>s>>n;
	sum1=s;
	tc(n)
	{
		cin>>a>>b;
		m.insert(mp(a,b));
	}
	for(it=m.begin();it!=m.end();it++)
	{
		if(s>it->fi)
			sum1+=it->se;
		//cout<<it->fi<<" "<<it->se<<endl;
	}
	for(it=m.begin();it!=m.end();it++)
	{
		if(s<=it->fi)
		{
			if(sum1<=it->fi)
			{
				cout<<"NO";
				return 0;
			}
			else
			{
				sum1+=it->se;
			}
		}
	}
	cout<<"YES";

	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int s,n,i;
	cin>>s>>n;
	int sum1=s;
	int *arr=new int[n];
	int *brr=new int[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i]>>brr[i];
		if(s>=arr[i])
		{
			sum1+=brr[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(s<arr[i])
		{
			if(sum1<arr[i])
			{
				cout<<"NO";
				return 0;
			}
		}
	}
	cout<<"YES";
}


var l=readline().split(' ');
var s=+l[0];
var n=+l[1];
var a=[];
for(var i=0;i<n;i++){
	a.push(readline().split(' ').map(function(v){return+v}));
}
a.sort(function(a,b){return a[0]-b[0]});

for(var i=0;i<n;i++){
	if(a[i][0]<s){
		s+=a[i][1];
	}else{
		break;
	}
}
print(i==n?'YES':'NO')


var l=readline().split(' ');
var s=+l[0];
var n=+l[1];
var a=[];
for(var i=0;i<n;i++){
	a.push(readline().split(' ').map(function(v){return+v}));
}
a.sort(function(a,b){return a[0]-b[1]});

for(var i=0;i<n;i++){
	if(a[i][0]<s){
		s+=a[i][1];
	}else{
		break;
	}
}
print(i==n?'YES':'NO')


var input = readline().split(" "), s = +input[0], n = +input[1];

for(var i = 0; i < n; i++){
	x = readline().split(" ");
	y = +x[1];
	x = +x[0];

	if(s > x){
		s += y;
	}
	else{
		write("NO");
		break;
	}
}

if(i == n){
	write("YES");
}


function sorting(){
	var buf1, buf2;
	for(i = 0; i <= +(n-2); i++){
		for(j = i+1; j <= +(n-1); j++){
			if(+y[i] > +y[j]){
				buf1 = y[i];
				y[i] = y[j];
				y[j] = buf1;
				buf2 = x[i];
				x[i] = x[j];
				x[j] = buf2;
			}
		}
	}
}

var input = readline().split(" "), s = +input[0], n = +input[1], x = [], y = [];
for(i = 0; i < n; i++){
	input = (readline().split(" "));
	x[i] = +input[0];
	y[i] = +input[1];
}

sorting();

for(i = 0; i < x.length; i++){
	if(s > x[i]){
		s += y[i];
		x.splice(i,1);
		y.splice(i,1);
		i = -1;
	}
}

if(x.length == 0){
	write("YES");
}
else{
	write("NO");
}


#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
using namespace std;
const int N = 110;
vector<string> vc;
unordered_multiset<string> st;
string ans = "", gt;
int mid, n, kol[26], cur_kol[26], cnt[N][26], real_cnt[N][26];

void calc(int l, int r, bool insrt){
    cout << "? " << l << " " << r << endl;

    int len = (r - l + 1);
    int kol = (len * (len + 1)) / 2;

    for (; kol; kol--){
        cin >> gt;

        sort(all(gt));

        if (insrt)
            st.insert(gt);
        else st.erase(st.find(gt));
    }
}

bool cmp(string _x, string _y){
    return sz(_x) < sz(_y);
}

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

    cin >> n;

    if (n < 4){
        for (int i = 1; i <= n; i++) {
            cout << "? " << i << " " << i << endl;

            cin >> gt;

            ans += gt;
        }

        cout << "! " << ans << endl;

        return 0;
    }

    mid = (n + 1) / 2;

    calc(1, mid, 1);
    calc(2, mid, 0);

    vc.clear();

    for (auto cr : st)
        vc.PB(cr);

    sort(all(vc), cmp);

    for (int i = 0; i < mid; i++){
        fill(cur_kol, cur_kol + 26, 0);

        for (int it = 0; it <= i; it++) {
            int ch = vc[i][it] - 'a';
            cur_kol[ch]++;

            if (cur_kol[ch] > kol[ch]){
                ans += char(ch + 'a');
                kol[ch] = cur_kol[ch];
            }
        }
    }

    mid = n / 2;

    cout << "? 1 " << n << endl;

    int subs = n * (n + 1) / 2;

    for (int it = 0; it < subs; it++){
        cin >> gt;

        int len = sz(gt);

        if (len == n){
            fill(cur_kol, cur_kol + 26, 0);

            for (int i = 0; i < n; i++)
                cur_kol[gt[i] - 'a']++;
        }

        for (int i = 0; i < len; i++)
            cnt[len][gt[i] - 'a']++;
    }

    for (int i = 2; i <= mid; i++)
    for (int ch = 0; ch < 26; ch++)
        real_cnt[i][ch] = cnt[i][ch] - cnt[i - 1][ch];

    fill(kol, kol + 26, 0);

    if (n & 1)
        kol[ans[mid] - 'a']++;

    for (int i = mid; i > 1; i--){
        kol[ans[i - 1] - 'a']++;

        for (int ch = 0; ch < 26; ch++)
            if (kol[ch] != real_cnt[i][ch]){
                ans += char('a' + ch);
                kol[ch]++;
                break;
            }
    }

    kol[ans[0] - 'a']++;

    for (int ch = 0; ch < 26; ch++)
        if (kol[ch] != cur_kol[ch]) {
            ans += char(ch + 'a');
            break;
        }

    cout << "! " << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
using namespace std;
const int N = 110;
vector<string> vc;
unordered_multiset<string> st;
string ans = "", gt;
int mid, n, kol[26], cur_kol[26], cnt[N][26], real_cnt[N][26];

void calc(int l, int r, bool insrt){
    cout << "? " << l << " " << r << endl;

    int len = (r - l + 1);
    int kol = (len * (len + 1)) / 2;

    for (; kol; kol--){
        cin >> gt;

        sort(all(gt));

        if (insrt)
            st.insert(gt);
        else st.erase(st.find(gt));
    }
}

bool cmp(string _x, string _y){
    return sz(_x) < sz(_y);
}

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

    cin >> n;

    if (n < 4){
        for (int i = 1; i <= n; i++) {
            cout << "? " << i << " " << i << endl;

            cin >> gt;

            ans += gt;
        }

        cout << "! " << ans << endl;

        return 0;
    }

    mid = (n + 1) / 2;

    calc(1, mid, 1);
    calc(2, mid, 0);

    vc.clear();

    for (auto cr : st)
        vc.PB(cr);

    sort(all(vc), cmp);

    for (int i = 0; i < mid; i++){
        fill(cur_kol, cur_kol + 26, 0);

        for (int it = 0; it <= i; it++) {
            int ch = vc[i][it] - 'a';
            cur_kol[ch]++;

            if (cur_kol[ch] > kol[ch]){
                ans += char(ch + 'a');
                kol[ch] = cur_kol[ch];
            }
        }
    }

    mid = n / 2;

    cout << "? 1 " << n << endl;

    int subs = n * (n + 1) / 2;

    for (int it = 0; it < subs; it++){
        cin >> gt;

        int len = sz(gt);

        for (int i = 0; i < len; i++)
            cnt[len][gt[i] - 'a']++;
    }

    for (int i = 1; i <= mid; i++)
    for (int ch = 0; ch < 26; ch++)
        real_cnt[i][ch] = cnt[i][ch] - cnt[i - 1][ch];

    fill(kol, kol + 26, 0);

    if (n & 1)
        kol[ans[mid] - 'a']++;

    for (int i = mid; i > 0; i--){
        kol[ans[i - 1] - 'a']++;

        for (int ch = 0; ch < 26; ch++)
            if (kol[ch] != real_cnt[i][ch]){
                ans += char('a' + ch);
                kol[ch]++;
                break;
            }
    }

    cout << "! " << ans << endl;

    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>

using namespace std;

void test() {
	int n = 9, i, j, k;

	vector<int> ct(n);

	for (i = 1; i <= n; i++) {
		cout << "Length = " << setw(3) << i << ": ";
		ct.assign(n, 0);
		for (j = 0; j + i <= n; j++) {
			for (k = 0; k < i; k++) ct[j + k]++;
		}
		for (auto p : ct) cout << setw(6) << p;
		cout << "\n";
	}
}

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
// initialize: UnionFind UF(N)

class UnionFind {                                              // OOP style
private:
	vector<int> p, rank, setSize;
	// p = path toward the root of disjoint set; p[i] = i means it is root
	// rank = upper bound of the actual height of the tree; not reliable as accurate measure
	// setSize = size of each disjoint set

	int numSets;
public:
	UnionFind(int N) {
		setSize.assign(N, 1);
		numSets = N;
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;	// each belongs to its own set
	}

	int findSet(int i) {
		return (p[i] == i) ? i : (p[i] = findSet(p[i]));		// path compression: cut short of the path if possible
	}

	bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	}

	void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			numSets--;
			int x = findSet(i), y = findSet(j);
			// rank is used to keep the tree short
			if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else {
				p[x] = y; setSize[y] += setSize[x];
				if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}

	int numDisjointSets() {		// # of disjoint sets
		return numSets;
	}

	int sizeOfSet(int i) {		// size of set
		return setSize[findSet(i)];
	}
};

void query(int a, int b, UnionFind &uf) {
	int n = b + 1 - a, i;
	for (i = a; i <= b; i++) uf.unionSet(i, b - (i - a));
}

vector<vector<int>> queryme(int a, int b) {
	int n = b + 1 - a, m = n * (n + 1) / 2, i, j, k, x;
	vector<vector<int>> ct(n + 1, vector<int>(26, 0));
	string s;

	cout << "? " << a << " " << b << "\n";
	cout.flush();
	for (i = 0; i < m; i++) {
		cin >> s;
		x = s.length();
		for (auto ch : s) ct[x][ch - 'a']++;
	}

	vector<vector<int>> ans((n + 1) / 2 + 1);
	vector<int> sct(26, 0);

	for (i = (n + 1) / 2; i >= 1; i--) {
		vector<int> cc(26);
		for (j = 0; j < 26; j++) cc[j] = ct[i][j] - ct[i - 1][j] - sct[j];
		for (j = 0; j < 26; j++) {
			sct[j] += cc[j];
			for (k = 0; k < cc[j]; k++)
				ans[i].push_back(j);
		}
	}
	return ans;
}

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

	int n, i, j, k;
	string ans;

	cin >> n;
	vector<vector<int>> q[3];

	if (n == 1) {
		q[0] = queryme(1, n);
		ans = " ";
		ans[0] = 'a' + q[0][1][0];
	}
	else if (n == 2) {
		q[0] = queryme(1, 1);
		q[1] = queryme(2, 2);
		ans = "  ";
		ans[0] = 'a' + q[0][1][0];
		ans[1] = 'a' + q[1][1][0];
	}
	else {
		vector<int> a(n + 1, -1);
		map<pair<int, int>, pair<int, int>> pp;
		queue<int> qq;
		int x = n / 2;

		if (n % 2 == 0) {
			q[0] = queryme(1, n);
			for (i = 1; i < q[0].size(); i++) pp[{i, n + 1 - i}] = { q[0][i][0], q[0][i][1] };

			q[1] = queryme(1, x);
			for (i = 1; i < q[1].size(); i++) {
				if (q[1][i].size() == 1) {
					a[i] = q[1][i][0];
					qq.push(i);
				}
				else pp[{i, x + 1 - i}] = { q[1][i][0], q[1][i][1] };
			}

			q[2] = queryme(x, n);
			for (i = 1; i < q[2].size(); i++) {
				if (q[2][i].size() == 1) {
					a[i + x - 1] = q[2][i][0];
					qq.push(i + x - 1);
				}
				else pp[{i + x - 1, n + 1 - i}] = { q[2][i][0], q[2][i][1] };
			}
		}
		else {
			q[0] = queryme(1, n);
			for (i = 1; i < q[0].size() - 1; i++) pp[{i, n + 1 - i}] = { q[0][i][0], q[0][i][1] };
			a[(n + 1) / 2] = q[0][(n + 1) / 2][0];
			qq.push((n + 1) / 2);

			q[1] = queryme(1, x);
			for (i = 1; i < q[1].size(); i++) {
				if (q[1][i].size() == 1) {
					a[i] = q[1][i][0];
					qq.push(i);
				}
				else pp[{i, x + 1 - i}] = { q[1][i][0], q[1][i][1] };
			}

			q[2] = queryme(x + 1, n);
			for (i = 1; i < q[2].size(); i++) {
				if (q[2][i].size() == 1) {
					a[i + x] = q[2][i][0];
					qq.push(i + x);
				}
				else pp[{i + x, n + 1 - i}] = { q[2][i][0], q[2][i][1] };
			}
		}

		while (!qq.empty()) {
			int id = qq.front();
			qq.pop();

			for (auto p : pp) {
				if ((p.first.first == id) || (p.first.second == id)) {
					int x = p.first.first + p.first.second - id;
					if (a[x] == -1) {
						a[x] = p.second.first + p.second.second - a[id];
						qq.push(x);
					}
				}
			}
		}

		ans = "";
		for (i = 1; i <= n; i++) {
			char ch = 'a' + a[i];
			ans = ans + ch;
		}
	}

	cout << "! " << ans << "\n";
	cout.flush();

	return 0;

	for (n = 4; n <= 100; n++) {
		UnionFind uf(n + 1);
		int x = n / 2;

		if (n % 2 == 0) {
			x++;
			query(1, n, uf);
			query(1, x, uf);
			query(x, n, uf);
		}
		else {
			//if (x % 2 == 1) x++;
			query(1, n, uf);
			query(1, x, uf);
			query(x + 1, n, uf);
		}

		int ct = 0;
		for (i = 1; i <= n; i++) {
			if (uf.findSet(i) == i) {
				//for (j = 1; j <= n; j++) {
				//	if (uf.findSet(j) == i) cout << j << " ";
				//}
				//cout << "\n";
				ct++;
			}
		}
		//cout << "Total Sets = " << ct << "\n";
		if (ct != 1) {
			break;
		}

	}

	return 0;
}