Is It a Tree?

No attempts yetTime limit1sMemory limit128 MB

Problem

A tree is a very well-known data structure. A data structure is a tree if it is either empty (it has $0$ nodes), or it has one or more nodes connected by directed edges and satisfies all of the following conditions.

If there is an edge from node $u$ to node $v$, we call this edge an outgoing edge with respect to $u$ and an incoming edge with respect to $v$.

  1. There is exactly one node with no incoming edge. This node is called the root.
  2. Every node other than the root has exactly one incoming edge.
  3. There is a path from the root to every other node, and that path is unique.

For example, some directed graphs satisfy all of these conditions and are trees, while others violate them and are not.

Given the edges, determine whether each graph is a tree.

Input

The input consists of several test cases.

Each test case consists of several pairs of integers. Each pair $u$, $v$ means that there is an edge from node $u$ to node $v$, where both $u$ and $v$ are greater than $0$. Each test case ends with a pair of two $0$s.

The end of the input is marked by a pair of two negative integers.

Output

For each test case, let $k$ be its case number (starting from $1$ and increasing by $1$). Print Case k is a tree. if the graph is a tree, or Case k is not a tree. otherwise.