#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))

typedef long long lint;
typedef pair<int, int> pii;

int N;
int M[110], L[110];
int S[110][20], E[110][20];

int T[110];
lint dp[2][(1<<17)];

void solve() {
	for_(i,0,N) {
		int t = 0;
		for_(j,0,M[i]) {
			int s = S[i][j], e = E[i][j];
			s -= 6; e -= 6;
			for_(k,s,e) t |= 1 << k;
		}
		T[i] = t;
	}
	
	minit(dp, -1);
	dp[0][0] = 0;
	
	for_(i,0,N) {
		int nw = i % 2, nx = (i + 1) % 2;
		int t = T[i];
		
		for_(j,0,(1<<17)) {
			if (dp[nw][j] < 0) continue;
			
			dp[nx][j] = max(dp[nx][j], dp[nw][j]);
			
			int ands = j & t;
			if (ands != 0) continue;
			
			int ors = j | t;
			dp[nx][ors] = max(dp[nx][ors], dp[nw][j] + (lint)L[i]);
		}
	}
	
	lint ans = 0;
	for_(i,0,(1<<17)) ans = max(ans, dp[N % 2][i]);
	cout << ans << endl;
}

int main() {
	while (cin >> N, N) {
		for_(i,0,N) {
			cin >> M[i] >> L[i];
			for_(j,0,M[i]) {
				cin >> S[i][j] >> E[i][j];
			}
		}
		solve();
	}
	return 0;
}