object Main extends App {
  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val count = Array.tabulate(n * 2){_ ⇒ 0}
  for (_ ← 0 until m){
    val Array(a, l) = readLine.trim.split(' ').map(_.toInt)
    count(a) += 1
    count(a + l) -= 1
  }
  var bias = 0
  for (x ← count){
    if (bias + x >= 0) bias += x
  }
  count(0) += bias
  for (i ← count.indices.tail){
    count(i) += count(i - 1)
  }
  val length = Array.tabulate(n){_ ⇒ 0}
  for (i ← length.indices){
    if (count(i) != 0 || count(i + n) != 0) length(i) = 1
  }
  for (i ← 1 to 2 * n){
    if (length(i % n) != 0) {
      length(i % n) = length((i - 1) % n) + 1
    }
  }
  val separated = length.indices.filter(i ⇒ length(i) != 0 && length((i + 1) % n) == 0)
  println(if (separated.nonEmpty) separated.map(length).groupBy(i ⇒ i).mapValues(_.length).toArray.sortBy(_._1)(Ordering.Int.reverse).map{case (len, c) ⇒ s"$len $c"}.mkString("\n") else s"$n 1")

  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}
