#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

ll dp[105][1<<16];

int main(void) {
    int i,j;
    int n;
    while(cin >> n, n){
        vector<pii> in(n);
        rep(i,n){
            int m;
            cin >> m >> in[i].second;
            int t[23]={};
            rep(j,m){
                int s,e;
                cin >> s >> e;
                t[s]++;
                t[e]--;
            }
            rep(j,22)t[j+1] += t[j];
            int ret = 0;
            rep(j,16)if(t[6+j])ret |= (1<<j);
            in[i].first = ret;
        }

        rep(i,105)rep(j,1<<16)dp[i][j]=-INF;
        dp[0][0] = 0;
        rep(i,n+1)rep(j,1<<16)if(dp[i][j]>-INF){
            dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
            if(!(j & in[i].first)){
                dp[i+1][j|in[i].first] = max(dp[i+1][j|in[i].first], dp[i][j]+in[i].second);
            }
        }
        ll ans = 0;
        rep(i,1<<16)ans = max(ans, dp[n][i]);
        cout << ans << endl;

    }
}

