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: import sys


# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

# ===CODE===
def main():
    while True:
        n = int(input())
        if n == 0:
            exit(0)

        d = [[[0 for i in range(60)] for j in range(60)] for k in range(24)]

        for _ in range(n):
            a, b = input().split()
            a_h, a_m, a_s = a.split(":")
            b_h,b_m,b_s = b.split(":")
            d[int(a_h)][int(a_m)][int(a_s)] += 1
            d[int(b_h)][int(b_m)][int(b_s)] -= 1

        ans = 0
        tmp_ans = 0
        for i in range(24):
            for j in range(60):
                for k in range(60):
                    tmp_ans += d[i][j][k]
                    ans = max(ans, tmp_ans)

        print(ans)


if __name__ == '__main__':
    main()

Python: from itertools import accumulate
while 1:
    n=int(input())
    if n==0:
        break
    timeline=[0 for i in range(86401)]
    for i in range(n):
        a,b=input().split()
        a=list(map(int,a.split(':')))
        b=list(map(int,b.split(':')))
        a=a[0]*3600+a[1]*60+a[2]
        b=b[0]*3600+b[1]*60+b[2]
        timeline[a]+=1
        timeline[b]-=1
    print(max(accumulate(timeline)))

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))

Python: import sys
import itertools
# import numpy as np
import time
import math
import heapq
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9 + 7

# map(int, input().split())
# list(map(int, input().split()))

while True:
    N = int(input())
    if N == 0:
        break
    times = [0] * (24 * 60 * 60 + 1)
    for i in range(N):
        line = input().split()
        start, end = 0, 0
        for j in range(2):
            h, m, s = map(int, line[j].split(":"))
            seconds = h * 60 * 60 + m * 60 + s
            if j == 0:
                start = seconds
            else:
                end = seconds
        times[start] += 1
        times[end] -= 1
    for i in range(1, 60 * 60 * 24 + 1):
        times[i] += times[i - 1]
    print(max(times))

Python: 
while True:
    N = int(input())
    if N == 0: break

    s = []
    for _ in range(N):
        d,a = input().split()
        s.append((d,1))
        s.append((a,-1))
    s.sort()
    s.append(('END',0))
    ans = 0
    cnt = 0
    bt = ''
    for t,c in s:
        if bt != t: ans = max(ans,cnt)
        cnt += c
        bt = t
    print (ans)

Python: while 1:
    n = int(input())
    if n==0:
        break
    ab = [list(input().split()) for _ in range(n)]
    
    T = [0] * (3600*24)
    
    for i in range(n):
        a, b = ab[i]
        a_h, a_m, a_s = map(int, a.split(':'))
        b_h, b_m, b_s = map(int, b.split(':'))
        a_time = a_h*3600 + a_m*60 + a_s
        b_time = b_h*3600 + b_m*60 + b_s
        T[a_time] += 1
        T[b_time] -= 1
        
    for i in range(1, len(T)):
        T[i] += T[i-1]
    
    print(max(T))

Python: m=24*60*60
while True:
	n=int(raw_input())
	if n==0:break
	dp=[0]*(m+1)
	for _ in range(n):
		a,d=raw_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))

Python: 
import itertools

ft=24*60*60
while True:
    n=int(input())
    if n==0:
        break
    c=[0]*(ft+1)
    for i in range(n):
        t1,t2=input().split()
        tt1=(int(t1[0:2])*60+int(t1[3:5]))*60+int(t1[6:8])
        tt2=(int(t2[0:2])*60+int(t2[3:5]))*60+int(t2[6:8])
        c[tt1]+=1
        c[tt2]-=1
    cc = itertools.accumulate(c)
    cc=list(cc)
    print(max(cc[:ft+1]))

Python: from itertools import accumulate

def main():
    def index_from_timer(time):
        hour=int(time[:2])
        minute=int(time[3:5])
        second=int(time[6:8])
        return hour*3600+minute*60+second

    while 1:
        n=int(input())
        if n==0:
            break
        timer=[input() for i in range(n)]
        A=[0 for _ in range(86400)]
        for time in timer:
            start=time[:8]
            end=time[9:]
            A[index_from_timer(start)]+=1
            A[index_from_timer(end)]-=1
        print(max(list(accumulate(A))))
main()

Python: def tosec(t):
    return int(t[:2])*60*60 + int(t[3:5])*60 + int(t[6:])

while True:
    n = int(input())
    if n == 0: break
    time = [0] * (60*60*24 + 1)

    for _ in range(n):
        s, f = input().split()
        time[tosec(s)] += 1
        time[tosec(f)] -= 1

    ans = time[0]
    for i in range(60*60*24):
        time[i+1] += time[i]
        ans = max(ans, time[i+1])

    print(ans)

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))