#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <iostream>
#include <map>
using namespace std;
struct Interval {
int l, r;
bool operator<(const Interval &a) const {
return l < a.l || (l == a.l && r < a.r);
}
};
int main() {
int n, m;
const int mod = 100000000;
Interval D[128];
while(scanf("%d %d", &m, &n) == 2 && n+m) {
for (int i = 0; i < n; i++) {
scanf("%d %d", &D[i].l, &D[i].r);
}
sort(D, D+n);
int dp[128][128] = {};
int ret = 0;
for (int i = 0; i < n; i++) {
dp[i][i] = (D[i].l == 0);
for (int j = i+1; j < n; j++) {
if (D[j].l > D[i].l && D[j].r > D[i].r && D[j].l <= D[i].r) {
for (int k = 0; k <= i; k++) {
if (D[k].r >= D[j].l && k != i)
continue;
dp[i][j] = (dp[i][j] + dp[k][i])%mod;
}
}
}
if (D[i].r == m) {
for (int j = 0; j <= i; j++)
ret = (ret + dp[j][i])%mod;
}
}
printf("%d\n", ret);
}
return 0;
}