import java.io.*; import java.util.*; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(1, in, out); out.close(); } static class Task { public void solve(int testNumber, InputReader in, PrintWriter out) { int N = in.nextInt(); int v[] = new int[N]; int w[] = new int[N]; int sum=0; for(int i=0; i<N; i++){ v[i] = in.nextInt(); w[i] = in.nextInt(); sum+=w[i]; } int V = in.nextInt(); int dp[] = new int[100005]; Arrays.fill(dp, -999999); dp[0] = 0; for(int i=0; i<N; i++){ for(int j=sum; j-w[i]>=0; j--){ dp[j] = Math.max(dp[j],dp[j-w[i]]+v[i]); } } int resmin=0; int resmax=0; int flag=0; for(int i=0; i<=sum; i++){ if(dp[i] == V&&flag==0){ resmin=i; flag++; } if(dp[i]>V){ resmax=i; break; } } out.println(Math.max(1,resmin)); if(resmax==0){ out.println("inf"); } else out.println(resmax-1); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }