/**
 * Created by IntelliJ IDEA.
 * User: o_215
 * Date: 28.10.2009
 * Time: 19:23:41
 * To change this template use File | Settings | File Templates.
 */
import java.util.*;
import java.io.*;

public class E {
    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 time=in.nextInt();
        int d1=in.nextInt();
        int d2=in.nextInt();
        int N=in.nextInt();
        if(d1==1 && time>120){time+=60;d1=0;}
        if(d1==-1 && time>180){time-=60;d1=0;}
        if(d2==1 && time>1560){time+=60;d2=0;}
        if(d2==-1 && time>1620){time-=60;d2=0;}
        int ttime=time%1440;
        for(int i=0;i<N;i++){
            if(d1==1 && time==119){time+=60;d1=0;}
            if(d1==-1 && time==179){time-=60;d1=0;}
            if(d2==1 && time==1559){time+=60;d2=0;}
            if(d2==-1 && time==1619){time-=60;d2=0;}
            out.print((ttime/60<10)?"0"+ttime/60+":":ttime/60+":");
            out.println((ttime%60<10)?"0"+ttime%60 :""+ttime%60);
            time++;ttime=time%1440;
        }
        in.close();
        out.close();
    }

}
