#include <iostream> #include <vector> #include <map> using namespace std; int main() { int n , M; cin>>n>>M; map<int,vector<pair<int,int>>> things; for(int i = 0 ; i < n ; i++){ int w,v,g; cin>>w>>v>>g; things[g].push_back({w,v}); ...