from datetime import timedelta

with open('ts.txt', 'r') as f:
    data = f.readlines()

with open('ts2.txt', 'r') as f:
    names = f.readlines()

for name, line in zip(names, data):
    name = name.strip()
    line = line.strip()
    ts, digit = line.split(': ')
    if '.' in ts:
        ts_s = ts.split('.')[0]
        ts_h, ts_m, ts_s = ts_s.split(':')
        td = timedelta(hours=int(ts_h), minutes=int(ts_m), seconds=int(ts_s))
        ts_us = int(ts.split('.')[1])
        if ts_us > 500000:
            td += timedelta(seconds=1)
        print(f"{str(td)[2:]} {name}")
    else:
        print(f"{str(ts)[2:]} {name}")

