#include <iostream>
#include <algorithm>
using namespace std;
int toMinutes(int hour, int minute) {
return hour * 60 + minute;
}
int main() {
int N;
int movieTimes[1000][100];
cin >> N;
for (int i = 0; i < N; i++) {
int movieHour, movieMinute;
cin >> movieHour >> movieMinute;
movieTimes[i][0] = movieHour;
movieTimes[i][1] = movieMinute;
}
int ch, cm;
cin >> ch >> cm;
int currentTimeInMinutes = toMinutes(ch, cm);
bool foundMovie = false;
for (int i = 0; i < N; i++) {
int movieTimeInMinutes = toMinutes(movieTimes[i][0], movieTimes[i][1]);
if (movieTimeInMinutes - currentTimeInMinutes >= 20) {
if(movieTimes[i][0]>=10){
cout << movieTimes[i][0] << " ";
}
else{
cout<< "0" << movieTimes[i][0] << " ";
}
if(movieTimes[i][1]>=10){
cout << movieTimes[i][1] << endl;
}
else {
cout << "0" << movieTimes[i][1] << endl;
}
foundMovie = true;
break;
}
}
if (!foundMovie) {
cout << "Too Late" << endl;
}
}