// Arup Guha
// 5/25/2013
// Solution to 2013 Rocky Mountain Regional Problem H: Trees

import java.util.*;

public class h {

	// Used for each problem instance.
	public static int[] component;
	public static ArrayList[] edgeList;
	public static int[] compSize;
	public static int[] edgeSize;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		int n = stdin.nextInt();
		int e = stdin.nextInt();
		int loop = 1;

		while (n != 0) {

			edgeList = new ArrayList[n];
			for (int i=0; i<n; i++) edgeList[i] = new ArrayList<Integer>();

			// Store edges one way.
			for (int i=0; i<e; i++) {
				int start = stdin.nextInt()-1;
				int end = stdin.nextInt()-1;
				edgeList[start].add(end);
				edgeList[end].add(start);
			}

			component = new int[n];

			// Find all components.
			int cur = 1;
			for (int i=0; i<n; i++) {
				if (component[i] == 0) {
					dfs(i, cur);
					cur++;
				}
			}

			// Store each component size and # edges in each component here.
			compSize = new int[cur];
			edgeSize = new int[cur];
			for (int i=n-1; i>=0; i--) {
				compSize[component[i]]++;
				edgeSize[component[i]] += edgeList[i].size();
			}

			// Determine whether or not each component is a tree.
			int cnt = 0;
			for (int i=1; i<compSize.length; i++) {
				if (edgeSize[i]/2 == compSize[i] - 1)
					cnt++;
			}

			// Output the solution.
			if (cnt > 1)
				System.out.println("Case "+loop+": A forest of "+cnt+" trees.");
			else if (cnt == 1)
				System.out.println("Case "+loop+": There is one tree.");
			else
				System.out.println("Case "+loop+": No trees.");


			// Go to next case.
			n = stdin.nextInt();
			e = stdin.nextInt();
			loop++;
		}
	}

	// Regular DFS; value marks the component.
	public static void dfs(int vertex, int value) {

		// Mark this one.
		component[vertex] = value;

		// Recursively mark neighbors.
		for (int i=0; i<edgeList[vertex].size(); i++) {
			int next = (Integer)edgeList[vertex].get(i);
			if (component[next] == 0)
				dfs(next, value);
		}
	}

}