아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Binary String

시간 제한3초메모리 제한256 MB

요약
각 조건마다 앞 y비트에 1이 정확히 x개 있거나 뒤 x비트에 1이 정확히 y개 있어야 할 때, 길이 n인 이진 문자열의 개수를 구한다.
난이도

보통10점 중 7점

유형
동적 계획법, 조합론, 누적 합
정답자
아직 제출이 없습니다

문제

Rikka has a binary string with nn bits.

We don't know the string. The thing we know for sure is, for each i∈1,2,…,mi \in \\{1, 2, \ldots, m\\}, at least one of the following is true: "there are exactly x_ix\_i ones in the first y_iy\_i bits" or "there are exactly y_iy\_i ones in the last x_ix\_i bits".

Find the number of possible binary strings modulo 998,244,353998\\,244\\,353.

입력

The first line contains an integer TT which denotes the number of test cases (1≤T≤51 \leq T \leq 5). 

For each test case, the first line contains two integers nn and mm (1≤n≤50001 \leq n \leq 5000, 0≤m≤10000 \leq m \leq 1000).

The ii-th of the following mm lines contains two integers x_ix\_i and y_iy\_i (0≤x_i,y_i≤n0 \leq x\_i, y\_i \leq n, x_i≠0x\_i \neq 0 or y_i≠0y\_i \neq 0).

출력

For each test case, print an integer which denotes the number of binary strings satisfying the constraints, modulo 998,244,353998\\,244\\,353.

예제1

  1. 예제 1

    입력
    2
    3 1
    2 1
    5 3
    1 3
    4 2
    3 1
    
    예상 출력
    4
    2