#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

typedef long long lli;

lli n, m[100], l[100], d[100], dp[2][1<<16];

int main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> m[i] >> l[i];
      d[i] = 0;
      for(int j=0;j<m[i];j++){
        lli a, b;
        cin >> a >> b;
        for(int k=a-6;k<b-6;k++) d[i] |= 1 << k;
      }
    }
    fill(dp[0], dp[2], -1);
    dp[0][0] = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<(1<<16);j++){
        if(dp[i%2][j] == -1) continue;
        dp[(i+1)%2][j] = max(dp[(i+1)%2][j], dp[i%2][j]);
        if((d[i] & j) == 0) dp[(i+1)%2][j|d[i]] = max(dp[(i+1)%2][j+d[i]], dp[i%2][j] + l[i]);
      }
    }
    lli ans = 0;
    for(int i=0;i<(1<<16);i++) ans = max(ans, dp[n%2][i]);
    cout << ans << endl;
  }
}