#include <bits/stdc++.h> using namespace std; int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; int f(int y) { return y%4==0 && y%100!=0 || y%400==0; } int main() { int n, y=1999, m=4, d=30; cin>>n; days[2]+=f(y); for(int i=1;i<=n;i++) { d++; if(d>days[m]) { d=1; m++; if(m>12) { y++; m=1; days[2]+=f(y); } } } cout<<y<<" "<<m<<" "<<d<<endl; return 0; }