#include <iostream>
using namespace std;
int main(){
int T;
cin >> T;
int a,b; // 계산시작할 날짜
int c,d; // 오늘 날짜
int day[13]={0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for(int t = 1;t<=T;t++){
//테스트케이스 수
cin >> a >> b >> c >> d;
for(int i=1;i<a;i++){
b += day[i];
}
for(int i=1;i<c;i++){
d += day[i];
}
cout << "#" << t << " " << d-b+1 << "\n";
}
return 0;
}
```