1. #include <iostream>
    2. #include <algorithm>
    3. using namespace std;
    4. class Solver {
    5. static const int MAXN = 100 + 5;
    6. static const int INF = 0x3f3f3f3f;
    7. int dp[MAXN] = {}, v[MAXN], w[MAXN];
    8. int V, n;
    9. void zeroOnePack() {
    10. for (int i = V; i >= 0; i--) {
    11. for (int j = 0; j < n; j++)
    12. if (i >= v[j]) dp[i] = max(dp[i], dp[i - v[j]] + w[j]);
    13. }
    14. }
    15. public:
    16. void f() {
    17. int N;
    18. cin >> N >> V;
    19. while (N--) {
    20. cin >> n;
    21. for (int i = 0; i < n; i++) cin >> v[i] >> w[i];
    22. zeroOnePack();
    23. }
    24. cout << dp[V] << endl;
    25. }
    26. };
    27. int main() {
    28. Solver s;
    29. s.f();
    30. }