#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
typedef pair<int, int> pii;

int main(){
	while(true){
		int N;
		cin >> N;
		if(N == 0){ break; }
		vector<pii> guys(N);
		for(int i = 0; i < N; ++i){
			int M, L, mask = 0;
			cin >> M >> L;
			for(int j = 0; j < M; ++j){
				int S, E;
				cin >> S >> E;
				S -= 6; E -= 6;
				mask |= ((1 << E) - 1) ^ ((1 << S) - 1);
			}
			guys[i] = pii(mask, L);
		}
		vector<int> dp(1 << (22 - 6));
		int answer = 0;
		for(int i = 0; i < dp.size(); ++i){
			answer = max(answer, dp[i]);
			for(int j = 0; j < N; ++j){
				int mask = guys[j].first;
				if(i & mask){ continue; }
				dp[i | mask] = max(dp[i | mask], dp[i] + guys[j].second);
			}
		}
		cout << answer << endl;
	}
	return 0;
}