/**
 * Created by IntelliJ IDEA.
 * User: m09aaa
 * Date: 11.11.2009
 * Time: 17:24:35
 * To change this template use File | Settings | File Templates.
 */
import java.util.*;
import java.io.*;

public class Cat {
        public static void main   ( String[] args ) throws Exception
        {
            Scanner in=new Scanner (new File("catt.in"));
            PrintWriter out=new PrintWriter (new File("catt.out"));
            int a=in.nextInt();
            a=a*60;
            int b=in.nextInt();
            b=b*60;
            int n=in.nextInt();
            String [] time=new String[n];
            int [] begin=new int[n];
            int [] end=new int[n];
            int i=0;
            boolean can=true;
            while (can&&i<n)
            {
                time[i]=in.next();
                if (time[i].length()>10)
                {
                    begin[i]=(time[i].charAt(0)-'0')*600+(time[i].charAt(1)-'0')*60+(time[i].charAt(3)-'0')*10+(time[i].charAt(4)-'0');
                    end[i]=(time[i].charAt(6)-'0')*600+(time[i].charAt(7)-'0')*60+(time[i].charAt(9)-'0')*10+(time[i].charAt(10)-'0');
                }
                if (end[i]-begin[i]>b)
                {
                    can=false;
                }
                else
                {
                    i++;
                }
            }
            if (can)
            {
                int k=0;
                int [][] sleep=new int [n][4];
                Arrays.sort(begin);
                Arrays.sort(end);
                i=0;
                while (can&&i<n)
                {
                    if ((begin[i]-end[i])<=a&((begin[(i+1)%n]-end[i])+24*60)%(24*60)<=a)
                    {
                        can=false;
                    }
                    else
                    {   if (((begin[(i+1)%n]-end[i])+24*60)%(24*60)>a)
                        {
                            sleep[k][0]=(end[i]+1)/60;
                            sleep[k][1]=(end[i]+1)%60;
                            sleep[k][2]=(begin[(i+1)%n]-1)/60;
                            sleep[k][3]=(begin[(i+1)%n]-1)%60;
                        }
                        else
                        {  if (((begin[(i+2)%n]-end[i])+24*60)%(24*60)<=a)
                            { sleep[k][0]=(end[i]+1)/60;
                            sleep[k][1]=(end[i]+1)%60;
                            sleep[k][2]=(begin[i]-1)/60;
                            sleep[k][3]=(begin[i]-1)%60;  }
                        }
                        k++;
                        i++;
                    }
                }
                if (can)
                {
                    out.println("Yes");
                    out.println(k);
                    for (i=0; i<k; i++)
                    {
                        String [][] c=new String[k][4];
                        for (int j=0; j<4; j++)
                        {
                            if (sleep[i][j]<=10)
                            {
                                c[i][j]="0";
                            }
                            else
                            {
                                c[i][j]="";
                            }

                        }
                        out.println(c[i][0]+sleep[i][0]+":"+c[i][1]+sleep[i][1]+"-"+c[i][2]+sleep[i][2]+":"+c[i][3]+sleep[i][3]);
                    }
                }
                else {out.println("No");}
            }
            else
            {
                out.println("No");
            }
            out.close();
        }
}

