#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int N;
    while (cin >> N, N) {
        V L(N);
        VV want(N, V(16, 0));
        rep(i, N) {
            int M;
            cin >> M >> L[i];
            rep(j, M) {
                int s, t;
                cin >> s >> t;
                rep2(k, s, t) want[i][k - 6] = 1;
            }
        }

        V dp(1 << 16, 0);
        rep(s, 1 << 16) {
            rep(i, N) {
                bool ok = true;
                rep(j, 16) {
                    if ( ((s >> j) & 1) && want[i][j] ) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    int ns = s;
                    rep(j, 16) {
                        ns |= want[i][j] * (1 << j);
                    }
                    dp[ns] = max(dp[ns], dp[s] + L[i]);
                }
            }
        }

        cout << *max_element(all(dp)) << endl;
    }

}