multiset<int>mst[(1<<5)+1]; multiset<int>::iterator it1,it2; int num[60020][10];
intmain(){ int n,m,od; while (~scanf("%d%d", &n, &m)){ for (int i = 0; i < (1<<5); i++) mst[i].clear(); for (int i = 1; i <= n; i++){ scanf("%d", &od); if (od == 0){ for (int j = 1; j <= m; j++) scanf("%d", &num[i][j]); for (int j = 0; j < (1 << m); j++){ int sum = 0; for (int k = 1; k <= m; k++){ if ((1<<(k-1)) & j) sum -= num[i][k]; else sum += num[i][k]; } mst[j].insert(sum); } }else { int x; scanf("%d", &x); for (int j = 0; j < (1 << m); j++){ int sum = 0; for (int k = 1; k <= m; k++){ if ((1<<(k-1)) & j) sum -= num[x][k]; else sum += num[x][k]; } it1 = mst[j].find(sum); mst[j].erase(it1); } } int ans = 0; for (int j = 0; j < (1 << m); j++){ it1 = mst[j].end(); it1--; it2 = mst[j].begin(); ans = max(ans,((*it1) - (*it2))); } printf("%dn", ans); }