def Map(): return list(map(int,input().split())) N,M,Q = Map() A,B = [0]*N,[0]*N for i in range(N): A[i],B[i] = Map() dp = [0 for i in range(1 << N)] for j in range(1 << N): a,b = 0,0 for i in range(N): if (j >> i) & 1: a += A[i] b += B[i] if a <= M: dp[j] = b for j in range(1 << N): for i in range(N): if (j >> i) & 1: k = j ^ (1 << i) dp[j] = max(dp[j],dp[k]) ans = 0 mask = (1 << N) - 1 for j in range(1 << N): a,b = 0,0 for i in range(N): if (j >> i) & 1: a += A[i] b += B[i] if a > Q: continue k = j ^ mask ans = max(ans,b + dp[k]) print(ans)