I'm Thinking of a Number

Let’s play a guessing game. I’m thinking of a positive integer that’s greater than five and less than eleven and divisible by three. Of course, I could be thinking of either six or nine. Your job is to supply a program that can play guessing games like this. Given a collection of clues, your program should report all numbers that satisfy the clues.

Input consists of a number of test cases (at most $20$). Each case starts with a number $1 \leq n \leq 10$ on a line by itself. Next come $n$ clues, one per line. Clues have the form “greater than $i$”, “less than $i$” or “divisible by $i$” for some integer $1 \leq i \le 50\, 000$. A value of zero for $n$ marks the end of all test cases.

For each test case, your program should report all positive integers that are consistent with the given clues. Values should be given on a single line in ascending order, with one space between consecutive values. If no values are consistent with the clues, print “none”. If infinitely many values are consistent with the clues, print out “infinite”.

Sample Input 1 | Sample Output 1 |
---|---|

3 less than 100 divisible by 3 divisible by 7 3 greater than 6 less than 9 divisible by 3 3 divisible by 1 greater than 6 greater than 500 1 less than 2 0 |
21 42 63 84 none infinite 1 |