#include <iostream>
using namespace std;
struct node
{
int x,y;
}t;
int tt,case_t;
int parent[105];
bool flag[105];
void makeset()
{
int xx;
for(xx=1;xx<100;xx++)
{
parent[xx]=xx;
flag[xx]=0;
}
}
int findset(int xx)
{
if(xx!=parent[xx])
parent[xx]=findset(parent[xx]);
return parent[xx];
}
void unionset(int xx,int yy)
{
xx=findset(xx);
yy=findset(yy);
if(xx==yy)
return ;
parent[yy]=xx;
}
int main()
{
int fir;
while(scanf("%d%d",&t.x,&t.y)!=EOF)
{
if(t.x==-1 && t.y==-1)
break;
if(t.x==0 && t.y==0)
{
printf("Case %d is a tree./n", ++case_t);
continue;
}
makeset();
flag[t.x]=flag[t.y]=1;
fir=t.x;
bool tree=1;
if(t.x==t.y)
tree=0;
else
unionset(t.x,t.y);
while(scanf("%d%d",&t.x,&t.y) &&t.x!=0)
{
flag[t.x]=flag[t.y]=1;
if(findset(t.x)==findset(t.y))
tree=0;
unionset(t.x,t.y);
}
for(int i=1;i<100;i++)
if(flag[i] && findset(i)!=findset(fir))
tree=0;
if(tree)
printf("Case %d is a tree./n", ++case_t);
else
printf("Case %d is not a tree./n", ++case_t);
}
return 0;
}