Under construction

Still being built. Things may change

Sister Ports

Time limit8sMemory limit512 MB

Summary
Count the perfect matchings of a planar graph formed by a convex polygon's boundary plus non-crossing chords, modulo 1000003.
Level

Hard8 of 10

Topics
Dynamic programming, Geometry, Combinatorics, Divide and conquer
Solved
No attempts yet

Problem

ACM is an island nation in the shape of a regular nn-gon. There are ports at the nn vertices, numbered 1 to nn clockwise starting from one vertex. Ports are treated as points.

ACM has two kinds of roads.

  1. Roads connecting adjacent ports Every pair of adjacent ports is connected by a road. That is, there is a road between ports whose numbers differ by 1, and between port 1 and port nn. There are nn roads of this kind.
  2. Roads passing through the interior of the island Some pairs of non-adjacent ports are also connected by roads. There are mm roads of this kind, and road ii connects port aia_i and port bib_i.

Roads are treated as line segments. In ACM, no two roads share a point other than an endpoint.

Figure G-1: An example of ports and roads

To prepare for accidents at ports, ACM decided to assign a sister port to every port so that any two ports can help each other at any time. Every port has exactly one sister port, and if port aa is the sister port of port bb, then port bb is also the sister port of port aa. That is, the nn ports are divided into n/2n/2 pairs of distinct ports. ACM further decided that there must be a road between sister ports.

Your job, as an excellent programmer living in ACM, is to write a program that computes the total number of ways to assign sister ports to all ports.

Figure G-2: Examples of assignments of sister ports (roads between sister ports are shown as thick red lines)

Input

The input consists of one or more data sets. Each data set has the following format.

n m
a1 b1
...
am bm

The first line contains two positive integers nn and mm, which are the number of ports in ACM and the number of roads of kind 2. The ii-th of the following mm lines contains two integers aia_i and bib_i, meaning that road ii connects ports aia_i and bib_i.

No two roads share a point other than an endpoint. The numbers have the following ranges.

  • 3≤n≤50,0003 \le n \le 50{,}000
  • 0≤m≤50,0000 \le m \le 50{,}000
  • 1≤ai,bi≤n1 \le a_i, b_i \le n

The end of the input is marked by a line containing two zeros.

Output

For each data set, output the total number of ways to assign sister ports modulo 10000031000003. If no valid assignment of sister ports exists, output 0.

Examples1

  1. Example 1

    Input
    6 1
    1 4
    8 3
    1 6
    1 5
    2 5
    12 3
    3 10
    4 9
    6 9
    3 0
    0 0
    
    Expected output
    3
    5
    7
    0