#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main ()
{
    int n, m;
    cin >> n >> m;
    vector<bool> v(n, false);
    for (int i = 0; i < m; i++) {
        int a, l;
        cin >> a >> l;
        for (int k = 0; k < l; k++) {
            v[(a + k) % n] = true;
        }
    }

    int s = 0;
    while (s < n && v[s]) {
        s++;
    }


    int count = 0;
    vector<int> res(n + 1, 0);

    if (s < n) {
        for (int i = 0; i <= n; i++) {
            if (v[(i + s) % n]) {
                count++;
            } else {
                if (count > 0) {
                    res[count]++;
                }
                count = 0;
            }
        }
    } else {
        res[n]++;
    }


    for (int i = n; i; i--) {
        if (res[i]) cout << i << " " << res[i] << endl;
    }

    return 0;
}
