#include using namespace std; typedef long long LL; typedef pair pp; LL q[22][1000005]; int len[22]; LL k[10003]; LL p[10003]; LL dp[40003]; const LL INF=1e18; int main() { int n,m; while(scanf("%d %d",&n,&m)!=EOF) { memset(len,0,sizeof(len)); int tank=0; LL life=0; for(int i=0 ; i