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