n, m = gets.chomp.split.map(&:to_i)
arr = Array.new(n, 0)

m.times{
    a, l = gets.chomp.split.map(&:to_i)
    l.times{|i| arr[(a + i) % n] = 1}
}

zero = arr.index(0)
if zero.nil?
    puts "#{n} 1"
else
    h = Hash.new{|h, k| h[k] = 0}
    l = 0
    zero.upto(zero + n - 1){|i|
        case arr[i % n]
        when 0
            if l != 0
                h[l] += 1
                l = 0
            end
        when 1
            l += 1
        end
    }
    h[l] += 1 if l != 0
    h.sort_by{|k, v| -k}.each{|k, v| puts "#{k} #{v}"}
end
