// Arup Guha
// Started on 10/9/04, finished on 10/11/04.
// Solution to 1997 SE Regional problem Bendy.

// The idea behind the solution is as follows: The carrying case is a
// circle centered at the origin with a radius of 25. The starting point
// for the first segment of straw is the point (0, -25) and the initial
// direction is MOVE_PX, which is point in the direction of the positive
// y-axis. For each straw, I determine recursively if it is viable.
// Here's the basic idea behind the recursion: Check if the current
// position of the straw is out of bounds. If so, return false. Otherwise,
// see if you've already finished the last bend of the straw, if so, 
// return true. If not, recursively try the next bend. First try not 
// bending the straw. If this works, then return true and don't bother
// trying to bend this joint. If not, try either one or two bends,
// recursively based on the type of joint. Return the or of the answers!

#include <iostream.h>

// Constants for type of straw
const int LEFT  = 1;
const int RIGHT = 2;
const int BOTH  = 3;

// These are misleading constants, MOVE_PX actually means that the 
// current straw direction is pointing down the positive y-axis while
// MOVE_PY means that the current straw direction is pointing down the
// positive x-axis. I have no idea why I swapped the convention, but now
// that the program is done, I'm just gonna keep it!
const int MOVE_PX = 1;
const int MOVE_NX = 2;
const int MOVE_PY = 3;
const int MOVE_NY = 4;

// Stores a joint.
struct joint {
  int type;
  int marker;
};

bool canfit(struct joint bends[], int numbends, int tryjoint,
	    double x, double y, int orientation);

void main() {

  int length, numbends;
  struct joint bends[10];

  // Read until there's no more input.
  while (cin >> length) {

    // Sentinel terminating case.
    if (length == 0)
      break;

    // Read in the data.
    cin >> numbends;

    for (int i=0; i<numbends; i++) {
      cin >> bends[i].type;
      cin >> bends[i].marker;
    }
    bends[numbends].marker = length; // Implicitly, this is the last
				     // marker.
	
    // Must try the first segment straight already, then do the
    // recursion!
    if (canfit(bends, numbends, 0, 0, -25+bends[0].marker, MOVE_PX))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

}

// Returns true if an only if the straw signified in bends, with numbends
// number of bends where we are currently trying bend number tryjoint and
// are currently at location (x,y) heading the the given orientation
// can fit in the case!
bool canfit(struct joint bends[], int numbends, int tryjoint,
	    double x, double y, int orientation) {

  // Outside of the case!
  if (x*x+y*y > 625)
    return false;

  // We've already tried the whole straw and it fits!
  if (tryjoint == numbends)
    return true;

  // This is the length of the segment after the current joint.
  int len = bends[tryjoint+1].marker-bends[tryjoint].marker;

  // Try no bend first, there are four cases based on the four
  // possible orientations.
  if ((orientation == MOVE_PX) &&
     canfit(bends, numbends, tryjoint+1, x, y+len, MOVE_PX))
     return true;
  if ((orientation == MOVE_NX) &&
     canfit(bends, numbends, tryjoint+1, x, y-len, MOVE_NX))
     return true;
  if ((orientation == MOVE_PY) &&
     canfit(bends, numbends, tryjoint+1, x+len, y, MOVE_PY))
     return true;
  if ((orientation == MOVE_NY) &&
     canfit(bends, numbends, tryjoint+1, x-len, y, MOVE_NY))
     return true;

  // Do the four left turn cases.
  if (bends[tryjoint].type == LEFT && orientation == MOVE_PX)
    return canfit(bends, numbends, tryjoint+1, x-len, y, MOVE_NY);
  if (bends[tryjoint].type == LEFT && orientation == MOVE_NX)
    return canfit(bends, numbends, tryjoint+1, x+len, y, MOVE_NY);
  if (bends[tryjoint].type == LEFT && orientation == MOVE_PY)
    return canfit(bends, numbends, tryjoint+1, x, y+len, MOVE_PX);
  if (bends[tryjoint].type == LEFT && orientation == MOVE_NY)
    return canfit(bends, numbends, tryjoint+1, x, y-len, MOVE_NX);

  // Do the four right turn cases.
  if (bends[tryjoint].type == RIGHT && orientation == MOVE_PX)
    return canfit(bends, numbends, tryjoint+1, x+len, y, MOVE_PY);
  if (bends[tryjoint].type == RIGHT && orientation == MOVE_NX)
    return canfit(bends, numbends, tryjoint+1, x-len, y, MOVE_NY);
  if (bends[tryjoint].type == RIGHT && orientation == MOVE_PY)
    return canfit(bends, numbends, tryjoint+1, x, y-len, MOVE_NX);
  if (bends[tryjoint].type == RIGHT && orientation == MOVE_NY)
    return canfit(bends, numbends, tryjoint+1, x, y+len, MOVE_PX);

  // This is for a BOTH joint and checks if the orientation is down
  // the y-axis.
  if (orientation == MOVE_PX || orientation == MOVE_NX)
    return canfit(bends, numbends, tryjoint+1, x+len, y, MOVE_PY) ||
           canfit(bends, numbends, tryjoint+1, x-len, y, MOVE_NY);

  // No if needed since this is the last possible case: a BOTH joint
  // currently oriented on the x-axis
  return canfit(bends, numbends, tryjoint+1, x, y-len, MOVE_NX) ||
         canfit(bends, numbends, tryjoint+1, x, y+len, MOVE_PX);
  
}
