# sisendi korrektsuse kontrollija import sys def checktime(t): (h, m, s) = map(int, t.split(':')) if 0 > m or m > 59: return None if 0 > s or s > 59: return None return '{0:02}:{1:02}:{2:02}'.format(h, m, s) def checkpoint(p): if p in ['S', 'F', 'H']: return p p = int(p) if 200 > p or p > 1900: return None return p fi = open(sys.argv[1], 'rt') fo = open(sys.argv[2], 'wt') (t, l, x, y) = fi.readline().strip().split() (t, l, x, y) = (checktime(t), int(l), int(x), int(y)) if t is None or '03:00:00' > t or t > '48:00:00': sys.exit('T invalid') fo.write('{0} {1} {2} {3}\n'.format(t, l, x, y)) e = int(fi.readline().strip()) if 1 > e: sys.exit('E out of range') fo.write('{0}\n'.format(e)) for i in range(e): (s, d, t) = fi.readline().strip().split() (s, d, t) = (checkpoint(s), checkpoint(d), checktime(t)) if s is None: sys.exit('S[{0}] invalid'.format(i + 1)) if d is None: sys.exit('D[{0}] invalid'.format(i + 1)) if t is None: sys.exit('T[{0}] invalid'.format(i + 1)) fo.write('{0} {1} {2}\n'.format(s, d, t)) fi.close() fo.close()