use std::io::stdin;

fn main() {
    let mut line = String::new();

    let mut distance = 0;
    let mut before_time = 0;
    let mut speed = 0;
    loop {
        line.clear();
        stdin().read_line(&mut line).unwrap();
        if line.trim().is_empty() {
            break;
        }
        let mut iter = line.trim().split(' ');

        let mut time_str = iter.next().unwrap().split(':');

        let (h, m, s) = (
            time_str.next().unwrap().parse::<u64>().unwrap(),
            time_str.next().unwrap().parse::<u64>().unwrap(),
            time_str.next().unwrap().parse::<u64>().unwrap(),
        );
        let time = h * 3600 + m * 60 + s;
        distance = distance + speed * (time - before_time);
        if let Some(spd_str) = iter.next() {
            speed = spd_str.parse::<u64>().unwrap();
        } else {
            println!(
                "{:02}:{:02}:{:02} {:.2} km",
                h,
                m,
                s,
                distance as f64 / 3600f64
            );
        }
        before_time = h * 3600 + m * 60 + s;
    }
}
