Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n := io.NextInt()
		if n == 0 {
			break
		}
		accum := make([]int, 86401)
		for i := 0; i < n; i++ {
			s, e := io.Next(), io.Next()
			hs, _ := strconv.Atoi(s[:2])
			ms, _ := strconv.Atoi(s[3:5])
			ss, _ := strconv.Atoi(s[6:8])
			accum[hs*60*60+ms*60+ss]++
			he, _ := strconv.Atoi(e[:2])
			me, _ := strconv.Atoi(e[3:5])
			se, _ := strconv.Atoi(e[6:8])
			accum[he*60*60+me*60+se]--
		}
		ans := 0
		for i := 1; i < 86401; i++ {
			accum[i] += accum[i-1]
			ans = intMax(accum[i], ans)
		}
		io.Println(ans)
	}
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

Python: while True:
    n = int(input())
    if n == 0:
        break
        
    ta = [0] * 86400
    for _ in range(n):
        a,b = input().split()
        c,cc,ccc = int(a[0:2]),int(a[3:5]),int(a[6:8])
        d,dd,ddd = int(b[0:2]),int(b[3:5]),int(b[6:8])
        ta[c*3600+cc*60+ccc] += 1
        ta[d*3600+dd*60+ddd] -= 1

    for i in range(86400):
        if 0 < i:
            ta[i] += ta[i-1]

    ans = 0
    for i in range(86400):
        if ans < ta[i]:
            ans = ta[i]

    print(ans)

Python: while True:
    n=int(input())
    if n==0:break
    ans=0
    k=0
    l1=[]
    l2=[]
    for i in range(n):
        a=input()
        l1.append(int(3600*int(a[0:2])+60*int(a[3:5])+int(a[6:8])))
        l2.append(int(3600*int(a[9:11])+60*int(a[12:14])+int(a[15:17])))
    l1.sort()
    l2.sort()
    for t in l1:
        while t>=l2[0]:
            k+=1
            l2.pop(0)
        if k==0:
            ans+=1
        else:
            k-=1
    print(ans)

Python: def solve():
    while True:
        N = int(input())
        if N==0:
            return
        firsts = [0]*(86401)
        lasts = [0]*(86401)
        for i in range(N):
            a,b = input().split()
            h,m,s = a.split(':')
            t = 0
            for i,n in enumerate([h,m,s]):
                if n[0]=='0':
                    n = n[1]
                t += int(n)*60**(2-i)
            firsts[t] += 1
            h,m,s = b.split(':')
            t = 0
            for i,n in enumerate([h,m,s]):
                if n[0]=='0':
                    n = n[1]
                t += int(n)*60**(2-i)
            lasts[t] += 1
        now = 0
        ans = 0
        for f,l in zip(firsts,lasts):
            now += f-l
            ans = max(ans,now)
        print(ans)
solve()

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    N = int(input())
    if N == 0:
        break
    schedule = [0 for i in range(24*60*60)]
    for i in range(N):
        s,e = map(lambda x:list(map(int,x.split(':'))),input().split())
        schedule[s[0]*60*60+s[1]*60+s[2]] += 1
        schedule[e[0]*60*60+e[1]*60+e[2]] -= 1
    for i in range(1,24*60*60):
        schedule[i] += schedule[i-1]
    print(max(schedule))

Python: import itertools
while True:
    n = int(input())
    if n == 0:
        break
    time = [0]*(60*60*24)
    for _ in range(n):
        h, c = input().split()
        l = 60*60*int(h[0:2]) + 60*int(h[3:5]) + int(h[6:8])
        r = 60*60*int(c[0:2]) + 60*int(c[3:5]) + int(c[6:8])
        time[l] += 1
        time[r] -= 1
    cumsum = list(itertools.accumulate(time))
    print(max(cumsum))

Python: def time_to_i(s):
    tt = list(map(int, s.split(':')))
    return tt[0] * 3600 + tt[1] * 60 + tt[2]

while True:
    n = int(input())
    if n == 0: break
    tmp = []
    for i in range(n):
        tmp.append(input().split())
    table = []
    for t in tmp:
        table.append((time_to_i(t[0]), 1)) # 1: departure, 0: arrival
        table.append((time_to_i(t[1]), 0))
    table.sort(key=lambda x:(x[0], x[1]))
    trains = 1
    for t in table:
        if t[1] == 1:
            if trains > 0:
                trains -= 1
        else:
            trains += 1
    print(trains)

Python: def f(s):
    return (s[0]*60+s[1])*60+s[2]
a=86401
while 1:
    t=[0]*a
    n=int(input())
    if n==0:break
    for _ in range(n):
        b,c=input().split()
        b,c=list(map(int,b.split(':'))),list(map(int,c.split(':')))
        t[f(b)]+=1;t[f(c)]-=1
    d=0
    for i in range(1,a):
        t[i]+=t[i-1]
        d=max(d,t[i])
    print(d)

Python: while True:
    n = int(input())
    if n == 0: break
    
    trains = []
    for _ in range(n):
        dept, ariv = input().split()
        trains.append((dept, ariv))
    trains.sort(key=lambda x:x[0])
    dcheck = 0
    usecar = 0
    returntime = []
    for tridx in range(len(trains)):
        new = True
        for ariv in returntime:
            if ariv <= trains[tridx][0]:
                new = False
                returntime.remove(ariv)
                break
        if new: usecar += 1
        returntime.append(trains[tridx][1])
    print(usecar)

Python: from itertools import accumulate

while 1:
    n = int(input())
    if n == 0:
        exit()
    ans = [0]*(24*60*60+1)
    for _ in range(n):
        s, t = input().split()
        sl = s.split(':')
        tl = t.split(':')
        ans[int(sl[0])*3600+int(sl[1])*60+int(sl[2])] += 1
        ans[int(tl[0])*3600+int(tl[1])*60+int(tl[2])] -= 1
    print(max(list(accumulate(ans))))

Python: def f(s):
    return (s[0]*60+s[1])*60+s[2]
a=86400
while 1:
    t=[0]*a
    n=int(input())
    if n==0:break
    for _ in range(n):
        b,c = map(lambda x:list(map(int,x.split(':'))),input().split())
        t[f(b)]+=1;t[f(c)]-=1
    d=0
    for i in range(1,a):
        t[i]+=t[i-1]
        if d<t[i]:d=t[i]
    print(d)

Python: m=24*60*60
while True:
	n=int(input())
	if n==0:break
	dp=[0]*(m+1)
	for _ in range(n):
		a,d=input().split()
#		a,b,c=map(int,a.split(':'));
#		d,e,f=map(int,d.split(':'));
#		dp[a*3600+b*60+c]+=1
#		dp[d*3600+e*60+f]-=1
	for i in range(m):
		dp[i+1]+=dp[i]
	print(max(dp))