#include <stdio.h>
int main ()
{
int t ,cd ,cm , cy , bd, bm ,by ,x ,i ;
scanf ("%d",&t) ;
for (i=1 ; i<=t ; i++)
{
scanf ("%d/%d/%d",&cd ,&cm ,&cy) ;
scanf ("%d/%d/%d",&bd ,&bm ,&by) ;
if (cd < bd)
{
cd = cd +30 ;
cm-- ;
}
if (cm <bm)
{
cm = cm+ 12 ;
cy-- ;
}
x = cy - by ;
if (x < 0) printf ("Case #%d: Invalid birth date\n",i) ;
else if (x > 130) printf ("Case #%d: Check birth date\n",i) ;
else printf ("Case #%d: %d\n",i ,x) ;
}
return 0 ;
}
int main ()
{
int t ,cd ,cm , cy , bd, bm ,by ,x ,i ;
scanf ("%d",&t) ;
for (i=1 ; i<=t ; i++)
{
scanf ("%d/%d/%d",&cd ,&cm ,&cy) ;
scanf ("%d/%d/%d",&bd ,&bm ,&by) ;
if (cd < bd)
{
cd = cd +30 ;
cm-- ;
}
if (cm <bm)
{
cm = cm+ 12 ;
cy-- ;
}
x = cy - by ;
if (x < 0) printf ("Case #%d: Invalid birth date\n",i) ;
else if (x > 130) printf ("Case #%d: Check birth date\n",i) ;
else printf ("Case #%d: %d\n",i ,x) ;
}
return 0 ;
}