CF1679F.Formalism for Formalism
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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) . For convenience we complement all numbers with leading zeros in such way that each number from the given interval consists of exactly n decimal digits.
You are given a set of pairs (ui,vi) , where ui and vi are distinct decimal digits from 0 to 9 .
Consider a number x consisting of n digits. We will enumerate all digits from left to right and denote them as d1,d2,…,dn . In one operation you can swap digits di and di+1 if and only if there is a pair (uj,vj) in the set such that at least one of the following conditions is satisfied:
- di=uj and di+1=vj ,
- di=vj and di+1=uj .
We will call the numbers x and y , consisting of n digits, equivalent if the number x can be transformed into the number y using some number of operations described above. In particular, every number is considered equivalent to itself.
You are given an integer n and a set of m pairs of digits (ui,vi) . You have to find the maximum integer k such that there exists a set of integers x1,x2,…,xk ( 0≤xi<10n ) such that for each 1≤i<j≤k the number xi is not equivalent to the number xj .
输入格式
The first line contains an integer n ( 1≤n≤50000 ) — the number of digits in considered numbers.
The second line contains an integer m ( 0≤m≤45 ) — the number of pairs of digits in the set.
Each of the following m lines contains two digits ui and vi , separated with a space ( 0≤ui<vi≤9 ).
It's guaranteed that all described pairs are pairwise distinct.
输出格式
Print one integer — the maximum value k such that there exists a set of integers x1,x2,…,xk ( 0≤xi<10n ) such that for each 1≤i<j≤k the number xi is not equivalent to the number xj .
As the answer can be big enough, print the number k modulo 998244353 .
输入输出样例
输入#1
1 0
输出#1
10
输入#2
2 1 0 1
输出#2
99
输入#3
2 9 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9
输出#3
91
说明/提示
In the first example we can construct a set that contains all integers from 0 to 9 . 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: 01 and 10 . We can construct a set that contains all integers from 0 to 99 despite number 1 .