#include #include #include #include #include using namespace std; int n,m; int a,b; long long ans; int xu[15]; int getint() { int res=0; char ch=getchar(); while((ch<'0' || ch>'9') && ch!='-') ch=getchar(); bool fan=0; if(ch=='-') { fan=1; ch=getchar(); } while('0'<=ch && ch<='9') { res=res*10+ch-'0'; ch=getchar(); } if(fan) res=-res; return res; } int getnum() { int res=0; char ch=getchar(); while((ch<'0' || ch>'9') && ch!='-') ch=getchar(); return (ch-'0'); } void GetXu() { int i; for(i=11;i>=1;i--) xu[i]=getnum(); } bool A() { int i; for(i=2;i<=5;i++) { if(xu[i]!=xu[i-1]) return 0; } return 1; } bool B() { bool x=1,y=1; int i; for(i=2;i<=5;i++) { if(xu[i]!=xu[i-1]+1) x=0; } for(i=2;i<=5;i++) { if(xu[i]!=xu[i-1]-1) y=0; } return(x||y); } bool C() { int x=xu[8]*1000+xu[7]*100+xu[6]*10+xu[5]; int y=xu[4]*10+xu[3]; int z=xu[2]*10+xu[1]; if(x<1980 || x>2016) return 0; if(y<1 || y>12) return 0; if(y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12) { if(z<1 || z>31) return 0; } else if(y==4 || y==6 || y==9 || y==11) { if(z<1 || z>30) return 0; } else { if(x%4==0) { if(z<1 || z>29) return 0; } else { if(z<1 || z>28) return 0; } } return 1; } void f() { a=getint(); b=getint(); ans=0; while(n--) { GetXu(); if(A()) ans+=a; else if(B()) ans+=a; else if(C()) ans+=a; else ans+=b; } cout<