#include <iostream>
#include <string.h>
using namespace std;
typedef long long ll;
ll dp[101][(1<<16)];

int main(){

  while(1){
    int n,L[103],m,man[103],c;
    cin >> n;
    if(n==0) break;

    for(int i=1;i<=n;i++){
      cin >> m >>L[i];
      c=0;
      for(int j=0;j<m;j++) {
	int a,b;
	cin>>a>>b;
	for(int k=a-6;k<b-6;k++) c =(c|(1<<(15-k)));
      }
      man[i] = c;
    }

    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
      for(int j=0;j<(1<<16);j++){
        dp[i][j]=max(dp[i-1][j],dp[i][j]);
	if((j|man[i])<(1<<16)&&(j&man[i])==0)dp[i][(j|man[i])] = max(dp[i-1][(j|man[i])],dp[i-1][j]+L[i]);
      }

    ll ans = 0;
    for(int j=0;j<(1<<16);j++) ans = max(ans,dp[n][j]);
    cout << ans <<endl;
  }
  return 0;
}