loop {
	n = gets.to_i
	break if n == 0
	
	bits = [0] * n
	value = []
	n.times {|i|
		m, l = gets.split.map &:to_i
		value << l
		m.times {
			x, y = gets.split.map &:to_i
			(x..y-1).each{|k|
				bits[i] |= (1 << (k-1))
			}
		}
	}

	max = 0
	(1..(1<<n)-1).each{|x|
		a = (0..n-1).select{|i| x[i] == 1}
		next if a.size > 1 && a.map{|i| bits[i]}.inject(:&) > 0
		sum = a.map{|i| value[i]}.inject(:+)
		max = sum if sum > max
	}
	p max
}