1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cmath> 5 6 using namespace std; 7 8 struct node 9 { 10 int a,b; 11 bool operator <(node n) const 12 { 13 return b-a<n.b-n.a; 14 } 15 }bn[1100]; 16 17 int main() 18 { 19 int T; 20 scanf("%d",&T); 21 while(T--) 22 { 23 int v,n; 24 scanf("%d%d",&v,&n); 25 for(int i=0;i<n;i++) 26 { 27 scanf("%d%d",&bn[i].a,&bn[i].b); 28 } 29 sort(bn,bn+n); 30 int flag=-1; 31 for(int i=n-1;i>=0;i--) 32 { 33 if(v>=bn[i].b) 34 { 35 v-=bn[i].a; 36 } 37 else 38 { 39 flag=0; 40 break; 41 } 42 } 43 if(flag) 44 cout<<"Yes"<<endl; 45 else 46 cout<<"No"<<endl; 47 } 48 return 0; 49 }