#include <stdio.h>

int main(void)
{
	int h1, m1, h2, m2, k = 0;
	int wakeMin, sleepMin = 0;
	int ans;
	
	scanf("%d", &h1);
	scanf("%d", &m1);
	scanf("%d", &h2);
	scanf("%d", &m2);
	scanf("%d", &k);
	//printf("%d %d %d %d %d %d", h1, m1, h2, m2, k);
	
	wakeMin = 60*h1 + m1;
	sleepMin = 60*h2 + m2;
	
	printf("%d %d\n", wakeMin, sleepMin);
	ans = (sleepMin - wakeMin) - k;
	
	printf("%d",ans);
	return 0;
}