Peer Review

Time limit1sMemory limit128 MB

Summary
Given each author's institution and their K assigned papers to review, count how many papers violate review-count, self-review, collaborator, or duplicate-review rules.
Level

Medium4 of 10

Topics
Hash map, Simulation, Implementation
Solved
No attempts yet

Problem

At scientific conferences, researchers submit papers describing their ideas and then review one another's papers, so that only strong work is presented. The organizers assign the reviews under three rules:

  • Every paper must be reviewed exactly KK times — never more, never fewer.
  • A researcher must not review a paper written by a collaborator. Researchers collaborate when they belong to the same institution, and every author collaborates with themselves, so no one may review their own paper.
  • A researcher must not review the same paper more than once.

Write a program that checks whether a conference followed all three rules, so the organizers learn about any violation before it is too late.

Input

The input contains several test cases. The first line of each test case has two integers KK (1≤K≤51 \le K \le 5) and NN (1≤N≤10001 \le N \le 1000): KK is the number of reviews every paper is supposed to receive, and NN is the number of papers to review. Every paper has exactly one author and every author presents exactly one paper, so there are as many papers as authors.

Each of the next NN lines describes one author: the name of the institution the author belongs to, followed by the list of the KK papers that author was asked to review. Researchers from the same institution are assumed to collaborate; researchers from different institutions do not. Every institution name is shorter than 10 characters and consists only of upper- and lowercase letters with no whitespace. Papers are identified by the index of their author: paper 11 was written by the first author listed, and paper NN by the last.

A line containing K=0K = 0 and N=0N = 0 marks the end of the input and must not be processed.

Output

For each test case, print one line:

  • NO PROBLEMS FOUND if every paper obeyed all three rules.
  • 1 PROBLEM FOUND if exactly one paper broke a rule.
  • P PROBLEMS FOUND if PP papers broke a rule, where P≥2P \ge 2.

A paper that breaks several rules still counts as a single problem. Produce no output for the terminating 0 0 line.

Examples3

  1. Example 1

    Input
    2 3
    UCM 2 3
    UAM 1 3
    UPM 1 2
    2 3
    UCM 2 3
    UAM 1 2
    UPM 2 2
    0 0
    
    Expected output
    NO PROBLEMS FOUND
    3 PROBLEMS FOUND
    
  2. Example 2

    Input
    1 3
    UCM 2
    UAM 3
    UPM 1
    0 0
    
    Expected output
    NO PROBLEMS FOUND
    
  3. Example 3

    Input
    1 1
    UCM 1
    0 0
    
    Expected output
    1 PROBLEM FOUND