INF = 10 ** 9 N = int(input()) mx = 0 mn = INF v = [] w = [] for i in range(N): x, y = map(int,input().split(' ')) v.append(x) w.append(y) V = int(input()) dp = [0] * (200000) for i in range(1,200000): dp[i] = INF for i in range(N): for j in range(V+1)[::-1]: dp[j+v[i]] = min(dp[j+v[i]],dp[j] + w[i]) print(max(1,dp[V])) mx = INF for i in range(V+1,200000): mx = min(mx,dp[i]) if mx == INF: print("inf") else: print(mx-1)