#include<iostream>using namespace std;int n;void data(int y,int m,int d){ switch(m) { case 3: n=59+d; break; case 4: n=90+d; break; case 5: n=120+d; break; case 6: n=151+d; break; case 7: n=181+d; break; case 8: n=212+d; break; case 9: n=242+d; break; case 10: n=272+d; break; case 11: n=303+d; break; case 12: n=334+d; break; }}int main(){ int N; cin>>N; for(int i=0;i<N;i++) { int n1=0; int y,m,d; cin>>y>>m>>d; if(m==1) { cout<<d<<endl; } else if(m==2) { cout<<31+d<<endl; } if((n%4 ==0 && n0 != 0)||n@0 == 0) { data(y,m,d); n1=n; cout<<n1+1<<endl; } else { data(y,m,d); n1=n; cout<<n1<<endl; } }return 0;}