#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int n;
struct guy {
	int m, l;
	vi v;
	guy() {
		v.assign(16, 0);
	}
	
};
ll vtoi(vl v) {
	ll ret = 0;
	ll p = 1;
	REP(i, v.size()) {
		ret += p*v[i];
		p *= 2;
	}
	return ret;
}
vl itov(ll i) {
	vl ret(16);
	REP(j, 16) {
		ret[j] = i % 2;
		i /= 2;
	}
	return ret;
}
ll dfs(vector<guy> &guys, vl &dp,int s) {
	if (dp[s] != -1)return dp[s];
	vl v = itov(s);
	ll ret = 0;
	REP(i, n) {
		vl tmp = v;
		REP(j, 16)tmp[j] += guys[i].v[j];
		if (*max_element(ALL(tmp)) <= 1) {
			ret = max(ret, guys[i].l + dfs(guys, dp, vtoi(tmp)));
		}
	}
	return dp[s] = ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1)  {
		
		cin >> n;
		if (!n)break;
		vector<guy> guys(n);
		REP(i, n) {
			cin >> guys[i].m >> guys[i].l;
			REP(j, guys[i].m) {
				int s, t;
				cin >> s >> t;
				s -= 6; t -= 6;
				FOR(k, s, t)guys[i].v[k]++;
			}
			/*if (*max_element(ALL(guys[i].v)) > 1) {
				guys[i].l = 0;
				REP(j, 16) {
					guys[i].v[j] = 0;
				}
			}*/

		}
		vl dp(1 << 16, -1);
		vi used(16, 0);
		cout << dfs(guys, dp, 0) << endl;
	}
	return 0;
}