#include using namespace std; using ll = long long; int main(){ int n; cin >> n; vector c(n), v(n); vector> dp(n + 1, vector(n + 1, -(1ll << 62))); dp[0][0] = 0; ll cnt, w = 0, inc; for(int i = 0; i < n; i++){ cin >> c[i] >> v[i]; for(int j = 0; j < 23 && c[i] > 0; j++){ if(c[i] >= (1 << j)){ c[i] -= (1 << j); cnt = 1 << j; w = (i + 1) * cnt; inc = v[i] * cnt; }else{ cnt = c[i]; w = (i + 1) * cnt; inc = v[i] * cnt; c[i] = 0; } for(int i = n - cnt; i >= 0; i--){ for(int j = n - w; j >= 0; j--){ dp[i + cnt][j + w] = max(dp[i + cnt][j + w], dp[i][j] + inc); } } } } for(int i = 1; i <= n; i++)cout << *max_element(dp[i].begin(), dp[i].end()) << '\n'; }