object Main extends App {

  import scala.io.StdIn._

  val Array(n, m, l) = readLine.trim.split(' ').map(_.toInt)
  val classes = List.tabulate(m){_ ⇒
    val Array(d, a, k, t) = readLine.trim.split(' ').map(_.toInt)
    new Class(d, a, k, t)
  }.sortBy(_.from)
  println(calMaxHappiness(classes, l))
  def calMaxHappiness(classes: List[Class], limit: Int): Int = {
    val memo = Array.tabulate(classes.length){_ ⇒ Array.tabulate(limit){_ ⇒ None: Option[Int]}}
    def sub(classes: List[Class], rest: Int, current: Int = 0): Int = {
      if (rest == 0) 0
      else {
        classes match {
          case Nil ⇒ 0
          case h::t ⇒
            memo(current)(rest - 1) match {
              case Some(r) ⇒ r
              case None ⇒
                val use = h.value + sub(t.dropWhile(_.from < h.until), rest - 1, current + 1)
                val unuse = sub(t, rest, current + 1)
                memo(current)(rest - 1) = Some(math.max(use, unuse))
                math.max(use, unuse)
            }
        }
      }
    }
    sub(classes, limit)
  }

  case class Time(day: Int, time: Int) extends Ordered[Time] {
    override def compare(that: Time): Int = if (day == that.day){
      time.compare(that.time)
    }else {
     day.compare(that.day)
    }
  }
  class Class(d: Int, a: Int, k: Int, t: Int){
    val day = d
    val from = Time(day, a)
    val until = Time(day, a + k)
    val value = t
  }
}
