#include #include #include using namespace std; const int MAXN = 1000; int N, M, a[MAXN][MAXN], cost[MAXN][MAXN], treeCost; bool used[MAXN]; void input() { int c, d, p; scanf("%d%d", &N, &M); for(int i=0; i