#P8346. Unique Perfect Matching in a Bipartite Graph

    ID: 21525 Type: Default 1000ms 256MiB

Unique Perfect Matching in a Bipartite Graph

Unique Perfect Matching in a Bipartite Graph

You are given a bipartite graph with 2n vertices and m edges. The bipartite graph is divided into two parts: the left part and the right part, each containing exactly n vertices. The graph may contain duplicate edges. Your task is to determine whether the number of perfect matchings in the graph is exactly one.

A perfect matching is a set of n edges such that every vertex of the graph is incident to exactly one edge from this set. In mathematical terms, if we denote a matching as a set M, then M is a perfect matching if and only if:

$$|M|=n \quad \text{and} \quad \bigcup_{(u,v)\in M}\{u,v\} = \{1,2,\dots,2n\}.$$

If there exists exactly one perfect matching, output Renko; otherwise, output Merry.


Story: On a clear night by Tokyo's seaside, two friends, Renko and Merry, observed two distinct groups of stars. The left group of n stars (Renko stars) and the right group of n stars (Merry stars) are connected by m observed moving relationships. With the unique harmony of the universe in question, they wonder whether there is exactly one way to pair every star from the left with a star from the right using these relationships. Help resolve their debate!

inputFormat

The first line contains two integers n and m — the number of vertices in each part and the number of edges.

The following m lines each contain two integers u and v (1 ≤ u, v ≤ n) indicating that there is an edge between the u-th vertex of the left part and the v-th vertex of the right part. Note that there may be duplicate edges.

outputFormat

Output a single line: Renko if the number of perfect matchings is exactly one, or Merry otherwise.

sample

2 2
1 1
2 2
Renko