using namespace std;
bool isLeap(int yy)
{
if(yy % 400 == 0)
return true;
if(yy % 4 == 0 && yy % 100 != 0)
return true;
return false;
}
int main()
{
string m1;
string comma;
int d1;
int y1, y2;
int T;
int k = 0;
cin >> T;
while(T--)
{
int leap = 0;
cin >> m1 >> d1 >> comma >> y1;
if(isLeap(y1))
{
if(m1.compare("January") == 0)
leap++;
else if(m1.compare("February") == 0)
leap++;
}
cin >> m1 >> d1 >> comma >> y2;
if(isLeap(y2) && y1 != y2)
{
if(m1.compare("February") == 0)
{
if(d1 == 29)
leap++;
}
else if(m1.compare("January") == 0){}
else
leap++;
}
/* Q: 如何正確地求出區間[y1+1, y2-1]的閏年數? */
int uleap = (y2/4)-(y2/100)+(y2/400);
int lleap = (y1/4)-(y1/100)+(y1/400);
if(y1 != y2)
{
leap += ((uleap - lleap));
if(isLeap(y1) && isLeap(y2))
leap -= 1;
}
cout << "Case " << ++k << ": " << leap << '\n';
}
return 0;
}
if(isLeap(y1) && isLeap(y2))
leap -= 1;
}
if(lsLeap(y2))