#include <iostream>
#include <cstring>
using namespace std;

typedef long long ll;

static const int SIZE = (1 << 16);

int n, bit[102];
ll l[102], dp[102][SIZE + 2];

void solve(){
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < SIZE; j++){
      if(dp[i][j] == -1) continue;

      if((j & bit[i]) == 0){
        int cal = (j | bit[i]);
        dp[i + 1][cal] = max(dp[i + 1][cal], dp[i][j] + l[i]);
      }
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    }
  }

  ll res = 0;

  for(int j = 0; j < SIZE; j++){
    res = max(res, dp[n][j]);
  }

  cout<< res << endl;
}

int main(){
  while(cin >> n, n){
    for(int i = 0; i < n; i++){
      int m;
      cin >> m >> l[i];
      bit[i] = 0;

      for(int j = 0; j < m; j++){
        int s, e;
        cin >> s >> e;
        for(int k = s - 6; k < e - 6; k++){
          bit[i] |= (1 << k);
        }
      }
    }

    solve();
  }
}