using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
static int NN => int.Parse(ReadLine());
static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
public static void Main()
{
Solve();
}
static void Solve()
{
var c = NList;
var (n, m) = (c[0], c[1]);
var map = NArr(m);
WriteLine(Perm(n, m, map));
}
static long Perm(int n, int m, int[][] map)
{
Array.Sort(map, (l, r) => l[0].CompareTo(r[0]));
var p = Enumerable.Repeat(-1, n).ToArray();
var pos = Enumerable.Repeat(-1, n).ToArray();
var ans = 0L;
var ft = new FenwickTree(n + 1);
foreach (var info in map)
{
p[info[0] - 1] = info[1] - 1;
pos[info[1] - 1] = info[0] - 1;
ans += ft.Sum(n) - ft.Sum(info[1] - 1);
ft.Add(info[1] - 1, 1);
}
var mod = 998_244_353;
ans %= mod;
if (n > m)
{
var all = 1L;
var rest1 = 1L;
var inv2 = 499_122_177;
for (var i = 0; i < n - m; ++i)
{
all = all * (i + 1) % mod;
if (i + 1 < n - m) rest1 = rest1 * (i + 1) % mod;
}
ans = (ans + (long)(n - m) * (n - m - 1) % mod * inv2 % mod * inv2 % mod) % mod * all % mod;
var sub = 0L;
var count = new int[n];
for (var i = n - 1; i >= 0; --i)
{
if (p[i] < 0) ++count[i];
if (i + 1 < n) count[i] += count[i + 1];
}
var add = 0L;
for (var i = n - 1; i >= 0; --i)
{
if (pos[i] >= 0) add += count[pos[i]];
else sub = (sub + add % mod) % mod;
}
count = new int[n];
for (var i = 0; i < n; ++i)
{
if (p[i] < 0) ++count[i];
if (i > 0) count[i] += count[i - 1];
}
add = 0L;
for (var i = 0; i < n; ++i)
{
if (pos[i] >= 0) add += count[pos[i]];
else sub = (sub + add % mod) % mod;
}
ans = (ans + sub * rest1) % mod;
}
return ans;
}
static long Exp(long n, long k, int mod)
{
if (k == 0) return 1;
if (k == 1) return n % mod;
var half = Exp(n, k / 2, mod);
var result = (half * half) % mod;
return ((k % 2) == 0) ? result : ((result * n) % mod);
}
class FenwickTree
{
int size;
long[] tree;
public FenwickTree(int size)
{
this.size = size;
tree = new long[size + 2];
}
public void Add(int index, int value)
{
++index;
for (var x = index; x <= size; x += (x & -x)) tree[x] += value;
}
/// 先頭からindexまでの和(include index)
public long Sum(int index)
{
if (index < 0) return 0;
++index;
var sum = 0L;
for (var x = index; x > 0; x -= (x & -x)) sum += tree[x];
return sum;
}
/// Sum(x) >= value となる最小のxを求める
// 各要素は非負であること
public int LowerBound(long value)
{
if (value < 0) return -1;
var x = 0;
var b = 1;
while (b * 2 <= size) b <<= 1;
for (var k = b; k > 0; k >>= 1)
{
if (x + k <= size && tree[x + k] < value)
{
value -= tree[x + k];
x += k;
}
}
return x;
}
}
}