/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com)
 * Date: 2013.11.09
 */

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

const int M = 210;
const int Q = M * M * 8;

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

int n, sx, sy, ex, ey, u[M][M][4];
int d[M][M][4], p[M][M][4];
int qst = Q / 2, qen = Q / 2, qx[Q], qy[Q], qd[Q];

inline void mark( int x, int y, int dir )
{
  assert(0 <= x && x < M && 0 <= y && y < M);
  u[x][y][dir] = 1;
}

inline void add( int x, int y, int dir, int D, int P )
{
  D += (P != 0);
  if (!(0 <= x && x < M && 0 <= y && y < M) || d[x][y][dir] <= D)
    return;
  d[x][y][dir] = D;
  p[x][y][dir] = P;
  if (x == ex && y == ey && D <= 2)
  {
    puts("YES");
    int cnt = 0;
    do
    {
      P = p[x][y][dir];
      x -= dx[dir], y -= dy[dir];
      dir = (dir - P + 4) & 3;
      if (P)
        printf("%d %d %d\n", x - M / 2, y - M / 2, P), cnt++;
    } while (x != sx || y != sy);
    while (cnt < 2)
      printf("%d %d 1\n", M, M + cnt++);
    exit(0);
  }
  if (P)
    assert(qen < Q), qx[qen] = x, qy[qen] = y, qd[qen++] = dir;
  else
    assert(qst > 0), qx[--qst] = x, qy[qst] = y, qd[qst] = dir;
}

int main()
{
  #define NAME "majorhouse"
  assert(freopen(NAME ".in", "r", stdin));
  assert(freopen(NAME ".out", "w", stdout));

  assert(scanf("%d%d%d", &ex, &ey, &n) == 3);
  ex += M / 2, ey += M / 2;
  while (n--)
  {
    int x1, y1, x2, y2;
    assert(scanf("%d%d%d%d", &x1, &y1, &x2, &y2) == 4);
    assert(x1 < x2 && y1 < y2);
    x1 += M / 2, y1 += M / 2, x2 += M / 2, y2 += M / 2;
    for (int x = x1 + 1; x < x2; x++)
      mark(x, y1, 0), mark(x, y2, 2);
    for (int y = y1 + 1; y < y2; y++)
      mark(x1, y, 1), mark(x2, y, 3);
  }
  memset(d, 0x30, sizeof(d));
  add(sx = M / 2, sy = M / 2, 0, 0, 0);
  while (qst < qen)
  {
    int x = qx[qst], y = qy[qst], dir = qd[qst++], D = d[x][y][dir];
    for (int j = -1; j <= 1; j++)
    {
      int dir1 = (dir + j + 4) & 3;
      if (!u[x][y][dir1])
        add(x + dx[dir1], y + dy[dir1], dir1, D, j);
    }
  }
  puts("NO");
  return 0;
}
