Under construction

Still being built. Things may change

English Class

Time limit2sMemory limit1024 MB

Summary
Given K fixed segments in a matching of N left and N right points, count the ways to complete it into a beautiful answer modulo 998244353.
Level

Medium7 of 10

Topics
Combinatorics, Math, Implementation
Solved
No attempts yet

Problem

Bru received a matching problem in English class, in the form shown below.

The matching problem is solved with NN points on the left and NN points on the right, arranged vertically. More precisely, you may assume that for every integer ii with 1≤i≤N1 \le i \le N, there is one point at (1,i)(1, i) and one point at (2,i)(2, i) on the coordinate plane.

Each point has a label next to it. The label next to (1,i)(1, i) is a word, and the label next to (2,i)(2, i) is its meaning, both in English. Connect two points with a segment when the word and the meaning match. A correct solution makes every point an endpoint of exactly one segment, and every segment has one endpoint with x-coordinate 11 and the other with x-coordinate 22.

Bru tried hard but found only KK of the NN segments. He connected the remaining points so that the result is a correct answer.

While deciding how to connect the remaining points, Bru wanted the final answer to be a beautiful answer.

A correct answer is an answer that satisfies both conditions below.

  • Every segment has endpoints (1,i)(1, i) and (2,j)(2, j) for some 1≤i,j≤N1 \le i, j \le N (where ii and jj are integers).
  • All 2N2N points are endpoints of exactly one segment.

The figures below show correct and incorrect answers.

Correct answerIncorrect answerIncorrect answer

A beautiful answer is a correct answer that also satisfies both conditions below.

  • No three or more segments meet at one point.
  • There is no closed region enclosed by the segments. In other words, using only parts of the given segments, you cannot form a polygon with positive area.

The figures below show beautiful and non-beautiful answers.

Beautiful answerNot a beautiful answerNot a beautiful answer

Bru wants to count the beautiful answers he can build by connecting the remaining points while keeping the segments he has already drawn fixed.

Input

The first line contains two integers NN and KK.

Each of the next KK lines contains two integers UiU_i and ViV_i, separated by a space. This means that (1,Ui)(1, U_i) and (2,Vi)(2, V_i) are connected by a segment.

Output

Print the number of correct answers that can be made by connecting the remaining points, modulo 998 244 353998\ 244\ 353.

Constraints

  • 3≤N≤2×1053 \le N \le 2 \times 10^5
  • 0≤K≤N0 \le K \le N
  • 1≤Ui≤N1 \le U_i \le N (1≤i≤K1 \le i \le K)
  • 1≤Vi≤N1 \le V_i \le N (1≤i≤K1 \le i \le K)
  • Ui≠UjU_i \neq U_j (1≤i<j≤K1 \le i < j \le K)
  • Vi≠VjV_i \neq V_j (1≤i<j≤K1 \le i < j \le K)

Examples3

  1. Example 1

    Input
    4 1
    1 3
    
    Expected output
    2
    
  2. Example 2

    Input
    8 3
    1 3
    2 2
    3 1
    
    Expected output
    0
    
  3. Example 3

    Input
    7 0
    
    Expected output
    233