#P1679F. Formalism for Formalism

Formalism for Formalism

No submission language available for this problem.

Description

Yura is a mathematician, and his cognition of the world is so absolute as if he have been solving formal problems a hundred of trillions of billions of years. This problem is just that!

Consider all non-negative integers from the interval [0,10n)[0, 10^{n}). For convenience we complement all numbers with leading zeros in such way that each number from the given interval consists of exactly nn decimal digits.

You are given a set of pairs (ui,vi)(u_i, v_i), where uiu_i and viv_i are distinct decimal digits from 00 to 99.

Consider a number xx consisting of nn digits. We will enumerate all digits from left to right and denote them as d1,d2,,dnd_1, d_2, \ldots, d_n. In one operation you can swap digits did_i and di+1d_{i + 1} if and only if there is a pair (uj,vj)(u_j, v_j) in the set such that at least one of the following conditions is satisfied:

  1. di=ujd_i = u_j and di+1=vjd_{i + 1} = v_j,
  2. di=vjd_i = v_j and di+1=ujd_{i + 1} = u_j.

We will call the numbers xx and yy, consisting of nn digits, equivalent if the number xx can be transformed into the number yy using some number of operations described above. In particular, every number is considered equivalent to itself.

You are given an integer nn and a set of mm pairs of digits (ui,vi)(u_i, v_i). You have to find the maximum integer kk such that there exists a set of integers x1,x2,,xkx_1, x_2, \ldots, x_k (0xi<10n0 \le x_i < 10^{n}) such that for each 1i<jk1 \le i < j \le k the number xix_i is not equivalent to the number xjx_j.

The first line contains an integer nn (1n500001 \le n \le 50\,000) — the number of digits in considered numbers.

The second line contains an integer mm (0m450 \le m \le 45) — the number of pairs of digits in the set.

Each of the following mm lines contains two digits uiu_i and viv_i, separated with a space (0ui<vi90 \le u_i < v_i \le 9).

It's guaranteed that all described pairs are pairwise distinct.

Print one integer — the maximum value kk such that there exists a set of integers x1,x2,,xkx_1, x_2, \ldots, x_k (0xi<10n0 \le x_i < 10^{n}) such that for each 1i<jk1 \le i < j \le k the number xix_i is not equivalent to the number xjx_j.

As the answer can be big enough, print the number kk modulo 998244353998\,244\,353.

Input

The first line contains an integer nn (1n500001 \le n \le 50\,000) — the number of digits in considered numbers.

The second line contains an integer mm (0m450 \le m \le 45) — the number of pairs of digits in the set.

Each of the following mm lines contains two digits uiu_i and viv_i, separated with a space (0ui<vi90 \le u_i < v_i \le 9).

It's guaranteed that all described pairs are pairwise distinct.

Output

Print one integer — the maximum value kk such that there exists a set of integers x1,x2,,xkx_1, x_2, \ldots, x_k (0xi<10n0 \le x_i < 10^{n}) such that for each 1i<jk1 \le i < j \le k the number xix_i is not equivalent to the number xjx_j.

As the answer can be big enough, print the number kk modulo 998244353998\,244\,353.

Samples

Sample Input 1

1
0

Sample Output 1

10

Sample Input 2

2
1
0 1

Sample Output 2

99

Sample Input 3

2
9
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9

Sample Output 3

91

Note

In the first example we can construct a set that contains all integers from 00 to 99. It's easy to see that there are no two equivalent numbers in the set.

In the second example there exists a unique pair of equivalent numbers: 0101 and 1010. We can construct a set that contains all integers from 00 to 9999 despite number 11.