import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int x = Integer.parseInt(sa[1]); int y = Integer.parseInt(sa[2]); int[] a = new int[n]; int[] b = new int[n]; int[] c = new int[n]; for (int i = 0; i < n; i++) { sa = br.readLine().split(" "); a[i] = Integer.parseInt(sa[0]); b[i] = Integer.parseInt(sa[1]); c[i] = Integer.parseInt(sa[2]); } br.close(); long[][] dp = new long[x + 1][y + 1]; for (int i = 0; i < n; i++) { long[][] wk = new long[x + 1][y + 1]; for (int j = 0; j <= x; j++) { for (int j2 = 0; j2 <= y; j2++) { wk[j][j2] = Math.max(wk[j][j2], dp[j][j2]); int nj = j + a[i]; int nj2 = j2 + b[i]; if (nj <= x && nj2 <= y) { wk[nj][nj2] = Math.max(wk[nj][nj2], dp[j][j2] + c[i]); } } } dp = wk; } long ans = 0; for (int j = 0; j <= x; j++) { for (int j2 = 0; j2 <= y; j2++) { ans = Math.max(ans, dp[j][j2]); } } System.out.println(ans); } }