Problem: Problem Statement

Mr. Takatsuki, who is planning to participate in the Aizu training camp, has a poor house and does not have much money. Therefore, he is trying to save money by using the Seishun 18 Ticket. With only one 18 ticket, you can ride a local train all day long, and you can enter and exit the ticket gates freely (detailed usage rules are omitted).

The attraction of the 18 Ticket is that you can use your spare time to see local souvenirs at the station where you change trains. She wants to visit various stations during her trip because it is a great opportunity. However, since I don't want to miss the next train, I decided to look around the station only when the time between the time I arrived at the transfer station and the time I left the transfer station was T minutes or more.

You will be given a transfer plan using Mr. Takatsuki's 18 ticket, so output the name and time of the station you can look around. Please note that the station that departs first and the station that arrives last are not candidates for exploration.

Constraints

* 1 <= N <= 10
* 1 <= T <= 180
* st_timei, ar_timei
* Represented by "HH: MM", HH is 00 or more and 23 or less, and MM is 00 or more and 59 or less. HH is hours and MM is minutes.
* 00:00 <= st_time1 <ar_time1 <st_time2 <ar_time2 <... <st_timeN <ar_timeN <= 23:59
* st_namei, ar_namei
* A character string represented by uppercase and lowercase letters.
* 1 <= string length <= 50
* The names of the i-th arrival station ar_namei and the i + 1th departure station st_namei + 1 match.
* The names of st_name1, ar_nameN, and the transfer station are different character strings.

Input

Each data set is input in the following format.


N T
st_time1 st_name1 ar_time1 ar_name1
st_time2 st_name2 ar_time2 ar_name2
...
st_timeN st_nameN ar_timeN ar_nameN


N is an integer representing the number of times the train is boarded, and T is an integer representing the permissible time (minutes) to see the transfer station. Subsequently, train departure and arrival pairs are given over N lines. The input of each line means that the train that Mr. Takatsuki rides departs from the station of st_namei at the time of st_timei, and that the train that Mr. Takatsuki rides arrives at the station of ar_namei at the time of ar_timei.

Output

Output in the following format for each data set.


M
stay_name1 stay_time1
stay_name2 stay_time2
...
stay_nameM stay_timeM


M (0 <= M <= N -1) is an integer that represents the number of stations you can look around. Then, over M lines, a list of stations that can be visited is output in ascending order of time. Each line means that you can walk around the station of stay_namei for stay_timei minutes.

Examples

Input

N T
st_time1 st_name1 ar_time1 ar_name1
st_time2 st_name2 ar_time2 ar_name2
...
st_timeN st_nameN ar_timeN ar_nameN


Output

2
Kanazawa 55
Niitsu 24


Input

8 24
05:30 Kyoto 06:37 Maibara
06:50 Maibara 07:36 Tsuruga
07:42 Tsuruga 10:03 Kanazawa
10:58 Kanazawa 12:07 Toyama
12:15 Toyama 14:12 Naoetsu
14:29 Naoetsu 15:57 Nagaoka
16:11 Nagaoka 17:14 Niitsu
17:38 Niitsu 20:06 AizuWakamatsu


Output

2
Kanazawa 55
Niitsu 24


Input

1 180
10:44 Koriyama 11:52 AizuWakamatsu


Output

0

Solution (in JAVA):

Solution:
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
 
 
public class Main{
	
	public static class Train implements Comparable<Train> {
		String name;
		int come;
		int go;
		
		public Train(String name, int come, int go) {
			super();
			this.name = name;
			this.come = come;
			this.go = go;
		}
		
		@Override
		public int compareTo(Train o) {
			// TODO Auto-generated method stub
			return this.come - o.come;
		}
		
		public boolean test(final int T){
			if(this.go - this.come >= T){
				return true;
			}else{
				return false;
			}
		}
	}
	
	public static int get_time(Scanner sc){
		String[] input = sc.next().split(":");
		
		int hour = Integer.parseInt(input[0]);
		int minute = Integer.parseInt(input[1]);
		
		return hour * 60 + minute;
	}
	
    public static void main(String[] args) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	
    	final int N = sc.nextInt();
    	final int T = sc.nextInt();
    	
    	ArrayList<Train> list = new ArrayList<Train>();
    	
    	get_time(sc); sc.next();
    	for(int i = 0; i < N; i++){
    		int ar_time = get_time(sc);
    		String ar_name = sc.next();
    		
    		if(i == N - 1){
    			continue;
    		}
    		
    		int st_time = get_time(sc);
    		String st_name = sc.next();
    		
    		list.add(new Train(ar_name, ar_time, st_time));	
    	}
    	
    	for(Iterator<Train> iter = list.iterator(); iter.hasNext(); ){
    		Train train = iter.next();
    		
    		if(!train.test(T)){
    			iter.remove();
    		}
    	}
    	
    	Collections.sort(list);
    	
    	System.out.println(list.size());
    	for(Train train : list){
    		System.out.println(train.name + " " + (train.go - train.come));
    	}
    	
    }
     
}