#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 500010;

lint dp[110][1<<16];

int main(){
    int n, bit[30][30];
    For(i, 6, 22)For(j, i+1, 23){
        bit[i][j] = 0;
        For(k, i, j) bit[i][j] |= 1 << (k-6);
    }

    while(scanf("%d", &n) && n){
        int m[n], b[n]; lint L[n];
        rep(i, n){
            scanf("%d%lld", &m[i], &L[i]);
            b[i] = 0;
            rep(j, m[i]){
                int l, r;
                scanf("%d%d", &l, &r);
                b[i] |= bit[l][r];
            }
        }

        rep(i, n+1)rep(S, 1<<16) dp[i][S] = -1;
        dp[0][0] = 0;
        rep(i, n)rep(S, 1<<16)if(dp[i][S] >= 0){
            chmax(dp[i+1][S], dp[i][S]);
            if(!(S & b[i])){
                chmax(dp[i+1][S|b[i]], dp[i][S] + L[i]);
            }
        }
        lint ans = 0;
        rep(S, 1<<16) chmax(ans, dp[n][S]);
        printf("%lld\n", ans);
    }
}
