#include #include #include #include #include #include #include using namespace std; #include #include #include #include #include #include #pragma comment(linker, "/STACK:1024000000,1024000000") #include typedef long long LL; typedef unsigned long long ULL; const int INF = 1<<29; const LL mod = 1e9+7; int day[123]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int main() { int t,n,a,b; scanf("%d",&t); while(t--){ scanf("%d%d%d",&n,&a,&b); LL ans=0; char s[123]; for(int i=0;i2016) { ans+=b; continue; } if((year%4==0&&year%100!=0)||(year%400==0)) { if(m==2&&d>=1&&d<=29) { ans+=a; continue; } else if(m<=12&&m>=1&&m!=2&&d>=1&&d<=day[m]) { ans+=a; continue; } } else { if(m<=12&&m>=1&&d>=1&&d<=day[m]) { ans+=a; continue; } } ans+=b; } cout<