import sys input = lambda :sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) ms = lambda: map(str, input().split()) mf = lambda: map(float, input().split()) li = lambda: list(mi()) def main(): LIM = int(1e18) + 1 print(LIM) N, P, K = mi() dp = [[0 for __ in range(K + 1)] for _ in range(N + 1)] dp[0][0] = P for i in range(N): t, b = mi() for j in range(K + 1): dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]) if j < K: dp[i + 1][j + 1] = min(max(dp[i + 1][j + 1], dp[i][j] + (b if t == 1 else dp[i][j])), LIM) ans = dp[N][K] print(-1 if ans == LIM else ans) if __name__ == '__main__': main()