#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); i++)
using ll = long long int;

int main() {
  int N, K;
  ll P;
  cin >> N >> P >> K;
  vector<int> T(N), B(N);
  rep(i, N)
    cin >> T[i] >> B[i];
  vector<vector<ll>> dp(N+1, vector<ll> (K+1, 0));
  dp[0][0] = P;
  rep(i, N) {
    rep(j, K+1) {
      // not use
      dp[i+1][j] = dp[i][j];
      // use
      if (j > 0 && j <= i+1) {
	if (T[i] == 1)
	  dp[i+1][j] = max(dp[i][j-1] + B[i], dp[i+1][j]);
	if (T[i] == 2)
	  dp[i+1][j] = max(dp[i][j-1] * 2, dp[i+1][j]);
      }
      if (dp[i+1][j] > 1e18) {
	cout << -1 << endl;
	return 0;
      }
    }
  }
  rep(i, N+1) {
    rep(j, K+1)
      cout << dp[i][j] << " ";
    cout << endl;
  }
  cout << dp[N][K] << endl;
  return 0;
}