struct Item {
int a, b, c;
int id;
int ans;
explicit Item(int _a = 0, int _b = 0, int _c = 0) : a(_a), b(_b), c(_c) {}
};
struct cmpa {
bool operator()(const Item &lhs, const Item &rhs) const {
return lhs.a > rhs.a || (lhs.a == rhs.a && lhs.b < rhs.b)
|| (lhs.a == rhs.a && lhs.b == rhs.b && lhs.c < rhs.c);
}
};
struct cmpc {
bool operator()(const Item &lhs, const Item &rhs) const {
return lhs.c > rhs.c || (lhs.c == rhs.c && lhs.b < rhs.b)
|| (lhs.c == rhs.c && lhs.b == rhs.b && lhs.a < rhs.a);
}
};
priority_queue<Item, vector<Item>, cmpa> Qin;
priority_queue<Item, vector<Item>, cmpc> Qout;