Integers and Ranges

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

Isaac has a decimal integer a_1a_2a_n\overline{a\_1 a\_2 \dots a\_n}, possibly with leading zeroes. He knows that for mm ranges \[l_1,r_1],\[l_2,r_2],,\[l_m,r_m]\[l\_1, r\_1], \[l\_2, r\_2], \dots, \[l\_m, r\_m], it holds that a_l_i×a_l_i+1××a_r_imod9=0a\_{l\_i} \times a\_{l\_i + 1} \times \dots \times a\_{r\_i} \bmod 9 = 0. Find the number of valid integers a_1a_2a_n\overline{a\_1 a\_2 \dots a\_n}, modulo (109+7)(10^9+7).

입력

The input consists of several test cases and is terminated by end-of-file.

The first line of each test case contains two integers nn and mm.

The iith of the following mm lines contains two integers l_il\_i and r_ir\_i.

출력

For each test case, print an integer which denotes the result.

제한

  • 1n,m1031 \leq n, m \leq 10^3
  • 1l_ir_in1 \leq l\_i \leq r\_i \leq n
  • There are at most 100100 test cases.