#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << (x) << endl
int dp[1<<16];
int main(){
	while(true){
		int N,L[100],b[100]={};
		cin>>N;
		if(N==0) break;
		rep(i,1<<16) dp[i]=0;
		rep(i,N){
			int M;
			cin>>M>>L[i];
			rep(j,M){
				int s,e;
				cin>>s>>e;
				for(int k=s;k<e;k++) b[i]|=1<<(k-6);
			}
		}
		rep(i,N){
			for(int j=(1<<16)-1;j>=0;j--){
				if(j&b[i]) continue;
				dp[j|b[i]]=max(dp[j|b[i]],dp[j]+L[i]);
			}
		}
		int ans=0;
		rep(i,1<<16) ans=max(ans,dp[i]);
		cout<<ans<<endl;
	}
}