cin >> n >> m; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) cin >> a[i][j]; for (int i = 1; i <= n; ++i) cin >> w[i]; for (int i = 1; i <= n; ++i) id[i] = i; sort(id + 1, id + n + 1, [](constint &u, constint &v) { return w[u] < w[v]; }); int ans = 0, sum = 0; for (int o = 1, i = id[1]; o <= n; i = id[++o]) for (int j = 1; j <= m; ++j) { if (fabs(a[i][j]) < eps) continue; if (!p[j]) { p[j] = i, ++ans, sum += w[i]; break; } double t = a[i][j] / a[p[j]][j]; for (int k = j; k <= m; ++k) a[i][k] -= t * a[p[j]][k]; } cout << ans << " " << sum << "\n"; return0; }