The first line of the input is an integer T, the number of test cases.
In each test case, the first line is the money M(1<=M<=1000) that Fakosh would get after he typed "show me the money", and N(1<=N<=5), the number of kinds of the cannons or soldiers he would like to make. Each of the next N lines will contain two integers Ai(1<=Ai<=100) and Bi(1<=Bi<=5). Ai is the price of the cannon or soldier, Bi is the number of the cannon or soldier of this kind he would like to make.
// show_me_the_money.cpp
#include <stdio.h>
#include <iostream>
using namespace std ;
int main (){
int t = 0 ;
scanf("%d " , &t ) ;
for (int i = 0 ; i < t ; i ++ ){
int money = 0 , lines = 0 ;
scanf(" %d %d" , &money , &lines) ;
for(int j = 0 ; j < lines ; j ++){
int cannons = 0 , price = 0 ;
scanf(" %d %d" , &cannons , &price) ;
money -= cannons * price ;
}
if(money < 0 ){
printf("%s\n", "Not enough") ;
}
else {
printf("%d\n" , money ) ;
}
}
return 0 ;
}