#include<bits/stdc++.h>
#include <assert.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int dp[2][(1 << 16)] = {0};
        //memset(dp, -1, sizeof(dp));
        dp[0][0] = 0;

        rep(i,n){
            int m, l;
            int s, e;
            int mask = 0;

            cin >> m >> l;
            rep(j,m){
                cin >> s >> e;
                s-=6;
                e-=6;
                for(int k = s; k < e; k++){
                    mask |= (1 << k);
                }
            }
            rep(j,(1 << 16)){
                if(dp[i % 2][j] == -1) continue;
                if(j & mask) continue;
                dp[(i + 1) % 2][j | mask] = max(dp[(i + 1) % 2][j | mask], dp[i % 2][j] + l);
            }
            memcpy(dp[i % 2], dp[(i + 1) % 2], sizeof(dp[i % 2]));
        }
        int ans = 0;
        rep(i,(1 << 16)){
            ans = max(ans, dp[n % 2][i]);
        }
        cout << ans << endl;
    }
}