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

class time {
    public static void main(String[] args) throws Exception{
        Scanner in = new Scanner(new File("time.in"));
        PrintWriter out = new PrintWriter(new File("time.out"));
        int t = in.nextInt(), d1 = in.nextInt(), d2 = in.nextInt(), k = in.nextInt();
        int[] tm = new int[k];
        tm[0] = t;
        for(int i = 1; i < k; i++){
            tm[i] = tm[i - 1] + 1;
        }
        int d = 0;
        for(int i = 0; i < k; i++){
            if((d1 == 1) && (tm[i] >= 120))
                tm[i] = tm[i] + 60;
            else if((d1 == -1) && (tm[i] >= 180))
                tm[i] = tm[i] - 60;

           if(tm[i] >= 1440){
             tm[i] = tm[i] - 1440;
             if((d2 == 1) && (tm[i] >= 120))
               tm[i] = tm[i] + 60;
              else if((d2 == -1) && (tm[i] >= 180))
                tm[i] = tm[i] - 60;
           }

           int h = tm[i]/60, m = tm[i] - h*60;
           String hh = Integer.toString(h);
           String mm = Integer.toString(m);
           if(h < 10) hh = "0" + hh;
           if(m < 10) mm = "0" + mm;
           out.println(hh + ":" + mm);
        }
        in.close();
        out.close();
    }
}
