using namespace std;
#include<iostream>
#include<map>
#include<vector>
#include<fstream>
int abs(int a)
{
return a > 0 ? a : -a;
}
map<int, int> a;
void findafter(vector<pair<int,int>>&b, map<int, int>::iterator p,int temp,int strength){
while ((p != a.end()) && (abs(p->first - strength) == temp))
{
b.push_back(*p); p++;
}}
void findbefore(vector<pair<int, int>>&b, map<int, int>::iterator p1, int temp, int strength)
{
while ((p1 != a.begin()) && (abs(strength - p1->first) == temp))
{
b.push_back(*p1); p1--;
}
if (p1 == a.begin() && (abs(strength - p1->first) == temp))
b.push_back(*p1);
}
void fight(int id, int strength) {
int id1 = 100000000;
map<int, int>::iterator p = a.lower_bound(strength);
if (p == a.begin())