#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
ll dp[1<<16] = {};

int main(){
  int N;
  while(cin>>N && N){
    ll ans = 0;
    memset(dp, 0, sizeof(dp));
    REP(i, N){
      int M; ll L;
      cin>>M>>L;
      int mask = 0;
      REP(t, M){
        int S, E;
        cin>>S>>E;
        S -= 6; E -= 6;
        for(int j = S; j < E; j++) mask |= (1 << j);
      }
      for(int S = 0; S < 1<<16; S++)if((mask & S) == 0){
        int next = S | mask;
        dp[next] = max(dp[next], dp[S] + L);
      }
    }
    REP(i, 1<<16)ans = max(ans, dp[i]);
    cout<<ans<<endl;
  }
  return 0;
}