#include <string>
#include <vector>
using namespace std;
int solution(vector<int> bandage, int health, vector<vector<int>> attacks) {
int answer = 0;
int time = 0;
int conti = 0;
int attack_order = 0;
int health_x = health;
while(attack_order<attacks.size()){
time++;
conti++;
if(attacks[attack_order][0] == time){
health -= attacks[attack_order][1];
if(health <=0)
return -1;
conti = 0;
attack_order++;
} else {
if(conti == bandage[0]){
health += bandage[1] + bandage[2];
if(health > health_x)
health = health_x;
conti = 0;
} else {
health += bandage[1];
if(health > health_x)
health = health_x;
}
}
}
answer = health;
return answer;
}