√import scala.collection.mutable._

object Main extends App {
  val Array(r, c, n) = io.StdIn.readLine.split(" ").map(_.toInt)
  
  val lines = 1.to(n).map { _ => io.StdIn.readLine.split(" ").map(_.toInt) }
  
  val yes = lines.zipWithIndex.forall {
      case (Array(x1, y1, x2, y2), i) =>
      val isSplit =
        (x1 == 0 || x1 == r) &&
        (y1 == 0 || y1 == c) &&
        (x2 == 0 || x2 == r) &&
        (y2 == 0 || y2 == c)
    
     if (isSplit) {
       val (minX, maxX) = if (x1 < x2) (x1, x2) else (x2, x1)
       val (minY, maxY) = if (y1 < y2) (y1, y2) else (y2, y1)
       lines.take(i).forall {
         case Array(x3, y3, x4, y4) =>
           val isFailure = 
             minX <= x3 && x3 <= maxX &&
             minX <= x4 && x4 <= maxX &&
             minY <= y3 && y3 <= maxY &&
             minY <= y4 && y4 <= maxY
           !isFailure
       }
     } else {
       true
     }
  }
  
  println(if (yes) "YES" else "NO")
}