#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector v(n), w(n); vector dp(100000+10); REP (i, n) cin >> v[i] >> w[i]; int z; cin >> z; REP (i, n) { for (int j = dp.size() - 1; j >= w[i]; j--) { dp[j] = max(dp[j], dp[j-w[i]] + v[i]); } } int x = dp.size(), y = -1; REP (i, dp.size()) { if (dp[i] == z) { x = min(x, i); y = max(y, i); } } cout << max(1, x) << endl; if (y == dp.size() - 1) cout << "inf" << endl; else cout << y << endl; return 0; }