import java.util.*;
import java.io.*;
public class A implements Runnable{
    public int abs(int a){
      if(a < 0) a = a + 24*60;
      return a;
    }
    public void run(){
      try{
          Scanner in = new Scanner(new File("catt.in"));
          PrintWriter out = new PrintWriter(new File("catt.out"));
          int a = in.nextInt()*60;
          int b = in.nextInt()*60;
          int n = in.nextInt();
          String[] tmp = new String[n];
          int[] t1 = new int[n];
          int[] t2 = new int[n];
          for(int i = 0; i < n; i++){
             tmp[i] = in.next();
             t1[i] = (tmp[i].charAt(0)*10 + tmp[i].charAt(1))*60 + tmp[i].charAt(3)*10 + tmp[i].charAt(4) - 671*'0';
             t2[i] =1 + (tmp[i].charAt(6)*10 + tmp[i].charAt(7))*60 + tmp[i].charAt(9)*10 + tmp[i].charAt(10) - 671*'0';
         }
         boolean res = true;
         for(int i = 0; i < n; i++) {
            if(abs(t2[i]-t1[i]) > b) {
               res = false;
               break;
            }
         }
         int k = n;
         for(int i = 0; i < n-1; i++) {
            if(abs(t2[i+1]-t1[i])>b && abs(t1[i+1]-t2[i])<a){
               res = false;
               break;
            }
            if(abs(t1[i+1]-t2[i])<a)
                k = k-1;
         }
         if(!res)
            out.print("No");
         else{
            out.println("Yes");
            out.println(k);
            for(int i = 0; i < n-1; i++){
               if(abs(t1[i+1]-t2[i])>=a)
                out.format("%02d:%02d-%02d:%02d\n", (t2[i])/60, (t2[i])%60,(t1[i+1]-1)/60,(t1[i+1]-1)%60);
            }
             out.format("%02d:%02d-%02d:%02d", (t2[n-1])/60, (t2[n-1])%60,(t1[0]-1)/60,(t1[0]-1)%60);
          }
         in.close();
         out.close();
      }  catch(Exception e){
           e.printStackTrace();
           System.exit(1);
         }
    }
    public static void main(String[] args) {
       new Thread(new A()).start();
    }
}
