n, m, k = gets.split.map(&:to_i)
a = (0..1).map { gets.split.map(&:to_i) }.transpose
f = -> is {
    b = is.map {|i| a[i]}.sort_by!(&:first)
    has = m
    to_get = 0
    until b.empty? || has == 0
        if has >= b[-1][1]
            to_get += b[-1].reduce(:*)
            has -= b[-1][1]
        end
        b.pop
    end
    has + to_get
}
p (0..n-1).to_a.combination(k).map {|is| f[is]}.max
