// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-6
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
using namespace std;
// mylittledoge
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
int N,K;
cin >> K >> N;
vector< pair<int,int> > V(N);
for(int i =0; i < N; i++) {
cin >> V[i].ff >> V[i].ss;
if(V[i].ff > V[i].ss) swap(V[i].ff,V[i].ss);}
sort(V.begin(),V.end());
vector<int> B(30000,0);
int X =0;
for(int i =N-1; i >= 0; i--) {
int x =0;
for(int j =V[i].ff+10000; j <= V[i].ss+10000; j++) x +=B[j];
for(int j =V[i].ff+10000; j <= V[i].ss+10000; j++) {
if(x >= K) break;
if(B[j] == 0) B[j]++, x++, X++;}
}
cout << X << "\n";
for(int i =0; i < 30000; i++) if(B[i] == 1) cout << i-10000 << "\n";
return 0;}
// look at my code
// my code is amazing
Ly8gaW9zdHJlYW0gaXMgdG9vIG1haW5zdHJlYW0KI2luY2x1ZGUgPGNzdGRpbz4KLy8gYml0Y2ggcGxlYXNlCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPHN0YWNrPgojaW5jbHVkZSA8bGlzdD4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8aW9tYW5pcD4KI2RlZmluZSBkaWJzIHJlc2VydmU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