import java.io.*;
import java.util.*;
import java.math.*;

public class cat_aa implements Runnable {

	public static void main(final String[] args) {
		new Thread(new cat_aa()).start();
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;
	Random rand = new Random(this.hashCode());

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (final Throwable e) {
			e.printStackTrace();
			System.exit(566);
		}
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine(), "\n\t :-");
			} catch (final Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	void myAssert(final boolean u, final String message) {
		if (!u) {
			throw new Error("Assertion failed!!! " + message);
		}
	}

	int inBounds(final int x, final int l, final int r, final String name) {
		myAssert(l <= x && x <= r, name + " not in bounds!!! " + x
				+ " not in [" + l + ".." + r + "]");
		return x;
	}

	String FNAME = "cat";

	private void solve() throws IOException {
		int minSleep = inBounds(nextInt(), 1, 24, "a") * 60;
		int maxAwake = inBounds(nextInt(), 1, 24, "b") * 60;
		int n = inBounds(nextInt(), 1, 20, "n");
		int day = 24 * 60;
		int twoDays = 2 * day;
		boolean[] event = new boolean[twoDays];
		for (int i = 0; i < n; i++) {
			int l = 60 * nextInt() + nextInt();
			int r = 60 * nextInt() + nextInt();
			if (r < l) {
				r += day;
			}
			for (int j = l; j <= r; j++) {
				event[j] = true;
				event[(j + day) % twoDays] = true;
			}
		}
		for (int start = 0; start < event.length; start++) {
			if (!event[start] && event[(start + 1) % twoDays]) {
				boolean[][] a = new boolean[day + 1][2];
				int[][] len = new int[day + 1][2];
				// 0 - awake
				// 1 - sleep
				a[0][1] = true;
				for (int i = 1; i < a.length; i++) {
					boolean nothingInteresting = true;
					for (int j = 0; j <= i; j++) {
						if (j >= minSleep && a[i - j][0] && nothingInteresting) {
							a[i][1] = true;
							len[i][1] = j;
						}
						nothingInteresting &= !event[(start + i - j) % twoDays];
					}
					for (int j = 1; j <= maxAwake && j <= i; j++) {
						if (a[i - j][1]) {
							a[i][0] = true;
							len[i][0] = j;
							break;
						}
					}
				}
				if (a[day][1]) {
					ArrayList<Pair> al = new ArrayList<Pair>();
					int i = day;
					int j = 1;
					while (i > 0) {
						if (j == 1) {
							al.add(new Pair(start + i - len[i][j] + 1, start
									+ i));
						}
						i -= len[i][j];
						j ^= 1;
					}
					Collections.sort(al);
					out.println("Yes");
					out.println(al.size());
					for (Pair p : al) {
						out.println(time(p.l) + "-" + time(p.r));
					}
					return;
				}
			}
		}
		out.println("No");
	}

	class Pair implements Comparable<Pair> {
		public Pair(int i, int j) {
			l = i % (24 * 60);
			r = j % (24 * 60);
		}

		int l, r;

		@Override
		public int compareTo(Pair p) {
			if (l == p.l) {
				return r - p.r;
			}
			return l - p.l;
		}
	}

	private String time(int t) {
		t %= 24 * 60;
		int h = t / 60;
		int m = t % 60;
		return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m;
	}
}
