import java.util.ArrayList;
import java.util.Collections;

import ru.ifmo.testlib.Checker;
import ru.ifmo.testlib.InStream;
import ru.ifmo.testlib.Outcome;
import ru.ifmo.testlib.Outcome.Type;

public class Check implements Checker {
	final int MAXPLACE = 100000;

	class Passenger implements Comparable<Passenger> {
		int from, to;
		public int place;
		int id;

		public Passenger(int from, int to, int place, int id) {
			super();
			this.from = from;
			this.to = to;
			this.place = place;
			this.id = id;
		}

		@Override
		public int compareTo(Passenger p) {
			return to - p.to;
		}
	}

	class Event implements Comparable<Event> {
		int type;
		Passenger passenger;
		int stop;

		public Event(int type, Passenger passenger, int stop) {
			super();
			this.type = type;
			this.passenger = passenger;
			this.stop = stop;
		}

		@Override
		public int compareTo(Event e) {
			return stop - e.stop;
		}
	}

	class SegmentTree {
		int[] a;

		public SegmentTree() {
			a = new int[1 << 18];
		}

		int get(int l, int r) {
			l += 1 << 17;
			r += 1 << 17;
			int ans = 0;
			while (l < r) {
				if (l % 2 == 0) {
					ans += a[l];
				}
				l = l / 2;
				if (r % 2 == 1) {
					ans += a[r];
				}
				r = (r - 2) / 2;
			}
			if (l == r) {
				ans += a[l];
			}
			return ans;
		}

		void add(int x, int d) {
			x += 1 << 17;
			while (x > 0) {
				a[x] += d;
				x = (x - 1) / 2;
			}
			a[0] += d;
		}
	}

	public Outcome test(InStream inf, InStream ouf, InStream ans) {
		int n = inf.nextInt();
		long jans = ans.nextLong();
		long pans = ouf.nextLong();
		if (pans > jans) {
			return new Outcome(Type.WA, "Jury has better solution");
		}
		Passenger[] p = new Passenger[n];

		ArrayList<Event> es = new ArrayList<Event>();
		for (int i = 0; i < p.length; i++) {
			int from = inf.nextInt();
			int to = inf.nextInt();
			int place = ouf.nextInt();
			if (place <= 0 || place > MAXPLACE) {
				return new Outcome(Type.WA, "Place " + place + " out of range");
			}
			p[i] = new Passenger(from, to, place, i);
			es.add(new Event(1, p[i], from));
			es.add(new Event(-1, p[i], to));
		}
		Collections.sort(es);
		SegmentTree tree = new SegmentTree();
		long sum = 0;
		for (Event e : es) {
			if (e.type == 1) {
				if (tree.get(e.passenger.place, e.passenger.place) != 0) {
					return new Outcome(Type.WA, "Place " + e.passenger.place
							+ " busy");
				}
				sum += tree.get(0, e.passenger.place - 1);
				tree.add(e.passenger.place, 1);
			} else {
				tree.add(e.passenger.place, -1);
				sum += tree.get(0, e.passenger.place - 1);
			}
		}
		if (sum != pans) {
			return new Outcome(Type.WA, "Promise " + pans + ", but get " + sum);
		}
		if (pans < jans) {
			return new Outcome(Type.WA, "Contestant found better solution: " + pans + " instead of" + jans);
		}
		return new Outcome(Type.OK, "" + jans);

	}
}
 