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

int dp[101][1<<16];
int main(){
	int N;
	while(cin >> N&&N){
		memset(dp,0,sizeof(dp));
		for(int i = 0 ; i < N ; i++){
			int M,L;
			cin >> M >> L;
			int b = 0;
			for(int j = 0 ; j < M ; j++){
				int s,e;
				cin >> s >> e;
				s -= 6;
				e -= 6;
				b |= ((1<<(e-s))-1) << s;
			}
			for(int k = 0 ; k < (1<<16) ; k++){
				dp[i+1][k] = max(dp[i][k],dp[i+1][k]);
				if( k & b ) continue;
				dp[i+1][k|b] = max(dp[i+1][k|b],dp[i][k]+L);
			}
			
		}
		int res = 0;
		for(int i = 0 ; i < (1<<16) ; i++)
			res = max(res,dp[N][i]);
		cout << res << endl;
	}
}