#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sst stringstream
#define sz size()
#define vc vector
typedef vc<int> vi;
typedef vc<ll> vl;
typedef vc<string> vs;

int N,date[111],point[111];
int dp[111][1<<16];

int f(int cur,int mask){
	int& res=dp[cur][mask];
	if(res>-1)return res;
	if(cur==N)return res=0;
	res=f(cur+1,mask);
	if((date[cur]&mask)==date[cur]){
		res=max(res,point[cur]+f(cur+1,mask^date[cur]));
	}
	return res;
}

int main(){
	while(cin>>N && N){
		rep(i,N){
			int M;
			cin>>M>>point[i];
			date[i]=0;
			rep(j,M){
				int S,E;
				cin>>S>>E;
				rep2(k,S,E)date[i]|=1<<(k-6);
			}
		}
		memset(dp,-1,sizeof(dp));
		cout<<f(0,(1<<16)-1)<<endl;
	}
}