#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<deque>
#include<climits>
#include<map>
using namespace std;
typedef pair<long long,int> P;
struct Pox
{
  P p;
  int met;
  Pox(P p,int met):p(p),met(met){}
};

bool check(int a,int b)
{
  for(int i=6;i<=22;i++)
    {
      if(((a>>i) & 1) && ((b>>i) & 1))
	return false;
    }
  return true;
}

int main()
{
  int N;
  while(cin >> N,N)
    {
      //clock_t st,ed;
      //st = clock();
      vector<P> info;
      for(int i=0;i<N;i++)
	{
	  int M;
	  long long L;
	  cin >> M >> L;
	  int time = 0;
	  for(int j=0;j<M;j++)
	    {
	      int S,E;
	      cin >> S >> E;
	      int pre = 0;
	      pre = (1<<E)-1;
	      pre ^= (1<<S)-1;
	      time |= pre;
	    }
	  info.push_back(P(L,time));
	}
      long long ans = 0;
      deque<Pox> deq;//Pox(P(満足度、使った時間),会った人)
      for(int i=0;i<N;i++)
	deq.push_back(Pox(info[i],(1<<i))),ans = max(ans,info[i].first);
      /*
      int mex[(1<<23)-1];
      for(int i=0;i<(1<<23)-1;i++)
	mex[i] = 0;
      */
      map<int,long long> mex;
      while(!deq.empty())
	{
	  Pox pox = deq.front(); deq.pop_front();
	
	  P p = pox.p;
	  int met = pox.met;
	  for(int i=0;i<N;i++)
	    {
	      if((met >> i) & 1)
		continue;
	      if(!check(p.second,info[i].second))
		continue;
	      int pes = p.second|info[i].second;
	      if(mex[pes] < p.first+info[i].first)
		{
		  mex[pes] = p.first+info[i].first;
		  deq.push_back(Pox(P(p.first+info[i].first,pes),met|(1<<i)));
		  ans = max(ans,p.first+info[i].first);
		}
	    }

	}	
      cout << ans << endl;
      //ed = clock();
      //cout << setiosflags(ios::fixed) << setprecision(10) << (double)(ed-st)/CLOCKS_PER_SEC << endl;
    }
  return 0;
}