import java.util.*; public class Main { static int[] values; static int[] weights; static int[][] dp; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); values = new int[n]; weights = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); weights[i] = sc.nextInt(); } dp = new int[n][100001]; for (int[] arr : dp) { Arrays.fill(arr, -1); } int v = sc.nextInt(); int min = 0; int max = 0; for (int i = 1; i <= 100000; i++) { int x = dfw(n - 1, i); if (x == v) { if (min == 0) { min = i; } max = i; if (i == 100000) { System.out.println(min); System.out.println("inf"); return; } } } System.out.println(min); System.out.println(max); } static int dfw(int idx, int w) { if (w < 0) { return Integer.MIN_VALUE; } if (idx < 0) { return 0; } if (dp[idx][w] < 0) { dp[idx][w] = Math.max(dfw(idx - 1, w), dfw(idx - 1, w - weights[idx]) + values[idx]); } return dp[idx][w]; } }