#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n && n){
        vector<ll> l(n);
        vector<ll> mask(n,0);
        vector<vector<ll>> dp(2,vector<ll>(1LL << 16,-1));
        dp[0][0] = 0;
        rep(i,n){
            ll m;
            cin >> m >> l[i];
            rep(j,m){
                ll s,T;
                cin >> s >> T;
                s-=6; T-=6;
                FOR(k,s,T)mask[i] |= (1LL << k);
            }
        }
        rep(i,n){
            rep(j,1LL << 16){
                dp[(i+1)%2][j] = max(dp[i%2][j],dp[(i+1)%2][j]);
                if(mask[i] & j)continue;
                if(dp[i%2][j] == -1)continue;
                ll nxt = j | mask[i];
                dp[(i+1)%2][nxt] = max(dp[i%2][j]+l[i],dp[(i+1)%2][nxt]);
            }
        }
        ll ans = 0;
        rep(i,1LL << 16)ans = max(ans,dp[n%2][i]);
        cout << ans << endl;
    }
}
