967_A. Mind the Gap
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.

He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.

Find the earliest time when Arkady can insert the takeoff.

Input

The first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 60) — the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.

Each of next n lines contains two integers h and m (0 ≤ h ≤ 23, 0 ≤ m ≤ 59) — the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.

Output

Print two integers h and m — the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.

Examples

Input

6 60
0 0
1 20
3 21
5 0
19 30
23 40


Output

6 1


Input

16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59


Output

24 50


Input

3 17
0 30
1 0
12 0


Output

0 0

Note

In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.

In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.

In the third example Arkady can insert the takeoff even between the first landing.
```python

# -*- coding: utf-8 -*-
# @Date    : 2019-01-30 20:41:28
# @Author  : raj lath (oorja.halt@gmail.com)
# @Link    : link
# @Version : 1.0.0

from sys import stdin

max_val=int(10e12)
min_val=int(-10e12)

def read_int()     : return int(stdin.readline())
def read_ints()    : return [int(x) for x in stdin.readline().split()]
def read_str()     : return input()
def read_strs()    : return [x for x in stdin.readline().split()]


nb_landings, interval = read_ints()
prev_landing = 0
for _ in range(nb_landings):
    hour, minute = read_ints()
    last_landing = hour * 60 + minute
    if last_landing  - prev_landing <= interval:
        prev_landing = last_landing + interval + 1
    else:break
print(prev_landing //  60, prev_landing % 60)



```