#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

int t[4];
bool bio[1500][1500];
char dani[7][15]={"ponedjeljak", "utorak", "srijeda", "cetvrtak", "petak","subota", "nedjelja"};

struct vrijeme{
    int m,dan;
    vrijeme(){}
    vrijeme(int _m, int _dan){
        m=_m;
        dan=_dan;
    }
    bool operator<(const vrijeme a)const{
        if (dan!=a.dan)
            return dan<a.dan;
        return m<a.m;
    }
};

int main(){
    for (int i=0; i<4; i++){
        int temp;
        scanf("%d:%d",&t[i],&temp);
        t[i]=t[i]*60+temp;
    }
    vrijeme x(t[0],5),y(t[1],5);
    while(x.m!=y.m or x.dan!=y.dan){
        if (bio[x.m][y.m] and x.dan==y.dan){
            printf("nikad\n");
            return 0;
        }
        if (x.dan==y.dan)
            bio[x.m][y.m]=true;

        if (x<y){
            x.m+=t[2];
            x.dan+=x.m/1440;
            x.m%=1440;
        }
        else{
            y.m+=t[3];
            y.dan+=y.m/1440;
            y.m%=1440;
        }
    }
    x.dan%=7;
    printf("%s\n",dani[x.dan]);
    if (x.m/60<10)
        printf("0");
    printf("%d:",x.m/60);
    if (x.m%60<10)
        printf("0");
    printf("%d\n",x.m%60);
	return 0;
}
