#include<cstdio> usingnamespace std; template <classType> voidread(Type &x) { char c; bool flag = false; while ((c = getchar()) < '0' || c > '9') flag |= c == '-'; x = c - '0'; while ((c = getchar()) >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0'; if (flag) x = ~x + 1; } template <classType, class ...Rest> voidread(Type &x, Rest &...y){ read(x); read(y...); } template <classType> voidwrite(Type x) { if (x < 0) putchar('-'), x = ~x + 1; if (x > 9) write(x / 10); putchar('0' + x % 10); } typedeflonglong LL; constint N = 410, mod = 998244353; int n, m, f[N][N], cnt[N][N]; intbinpow(int b, int k = mod - 2) { int res = 1; for (; k; k >>= 1, b = (LL)b * b % mod) if (k & 1) res = (LL)res * b % mod; return res; } intmain() { read(n, m); for (int i = 1, l, r; i <= m; ++i) { read(l, r); for (int j = 0; j < l; ++j) for (int k = l; k <= r; ++k) ++cnt[j][k]; } f[0][0] = -1; int res = 0; for (int i = 0; i <= n; ++i) for (int j = 0; j <= m; ++j) { (res += (LL)m * binpow(j) % mod * f[i][j] % mod) %= mod; for (int k = i + 1; k <= n; ++k) (f[k][j + cnt[i][k]] -= f[i][j]) %= mod; } write((res + mod) % mod); return0; }