def main():
    N, P, K = map(int, input().split())
    dp_table = [0 for _ in range(K + 1)]
    dp_table[0] = P
    for _ in range(N):
        T, B = map(int, input().split())
        for k in reversed(range(K)):
            match T:
                case 1:
                    dp_table[k + 1] = max(dp_table[k + 1], dp_table[k] + B)
                case 2:
                    dp_table[k + 1] = max(dp_table[k + 1], dp_table[k] * 2)
    if dp_table[K] > int(1e18):
        print(-1)
    else:
        print(dp_table[K])


if __name__ == "__main__":
    main()