#include<iostream>
using namespace std;
bool isLeapYear(int &year)
{
if(year%4==0&&year%100!=0||year%400==0)
return true;
return false;
}
void calculateDays(int &year,int &month,int &day)
{
int sumDays=0;
for(int i=2000;i<year;i++){
if(isLeapYear(i))
sumDays+=366;
else
sumDays+=365;
}
int sumDays2=0;
switch(month)
{
case 12:
sumDays2+=30;
case 11:
sumDays2+=31;
case 10:
sumDays2+=30;
case 9:
sumDays2+=31;
case 8:
sumDays2+=31;
case 7:
sumDays2+=30;
case 6:
sumDays2+=31;
case 5:
sumDays2+=30;
case 4:
sumDays2+=31;
case 3:
if(isLeapYear(year))
sumDays2+=29;
else
sumDays2+=28;
case 2:
sumDays2+=31;
case 1:
sumDays2+=day;
}
cout<<sumDays+sumDays2-1<<endl<<sumDays2<<endl;
}
int main()
{
int y,m,d;
while(cin>>y)
{ if(y==-1)
break;
cin>>m>>d;
calculateDays(y,m,d);
}
return 0;
}