import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int N;

struct G {
    int T;
    int S;
}
G[] gs;

bool input() {
    scanf("%d\n", &N);
    if (N == 0) return false;
    gs = new G[N];
    foreach (i; 0 .. N) {
        int M, L; scanf("%d %d\n", &M, &L);
        gs[i].S = L;
        foreach (j; 0 .. M) {
            int S, E; scanf("%d %d\n", &S, &E);
            gs[i].T |= (1 << E) - (1 << S);
        }
    }
    return true;
}

void solve() {
    int dfs(int index, int T) {
        if (index == N) return 0;
        int ret = 0;
        if (!(T & gs[index].T)) {
            ret = dfs(index + 1, T | gs[index].T) + gs[index].S;
        }
        return max(ret, dfs(index + 1, T));
    }
    writeln(dfs(0, 0));
}

void main() {
    while (input) solve;
}