161 {
162 int year, day;
163 int day_of_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
164 int day_of_month_leap[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
165 int start_day_of_month[14] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, INT_MAX};
166 while(cin >> year >> day) {
167 bool leap = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
168 if(leap) {
169 for(int i = 1; i <= 12; i++) {
170 start_day_of_month[i] = start_day_of_month[i - 1] + day_of_month_leap[i - 1];
171 }
172 } else {
173 for(int i = 1; i <= 12; i++) {
174 start_day_of_month[i] = start_day_of_month[i - 1] + day_of_month[i - 1];
175 }
176 }
177 cout << setw(4) << setfill('0') << year << '-';
178 for(int i = 1; i <= 13; i++) {
179 if(start_day_of_month[i] > day) {
180 cout << setw(2) << setfill('0') << i - 1 << '-';
181 day -= start_day_of_month[i - 1];
182 day++;
183 cout << setw(2) << setfill('0') << day << endl;
184 break;
185 }
186 }
187 memset(start_day_of_month, 0, sizeof(start_day_of_month));
188 start_day_of_month[0] = 1;
189 start_day_of_month[13] = INT_MAX;
190 }
191 return 0;
192 }