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

C++: #include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int t[100010];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		memset(t,0,sizeof(t));
		rep(i,n){
			int h,m,s;
			scanf("%d:%d:%d",&h,&m,&s);
			t[h*3600+m*60+s]+=1;
			scanf("%d:%d:%d",&h,&m,&s);
			t[h*3600+m*60+s]-=1;
			//dbg(h); dbg(m); dbg(s);
		}
		rep(i,100000){
			t[i+1]+=t[i];
		}
		int res=0;
		rep(i,100000){
			maxch(res,t[i]);
		}
		cout<<res<<endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
 
using namespace std;

int main(void){

  int n;
  int sum[1024];

  while(1){
        scanf("%d",&n);
        if(n==0)break;
        memset(sum,0,sizeof(sum));
        for(int i=0;i<n;i++){
            int h,m,s;
            scanf("%2d:%2d:%2d",&h,&m,&s);
            sum[h*60*60+m*60+s]++;
            scanf("%2d:%2d:%2d",&h,&m,&s);
            sum[h*60*60+m*60+s]--;
        }
        int res=sum[0];
        for(int i=0;i<=24*60*60;i++){
            sum[i+1]+=sum[i];
            res=max(res,sum[i+1]);
        }
        printf("%d\n",res);
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;

    cin >> n;

    vector<int> retime(360000);
    int ans = 0;
    while (n != 0)
    {
        for (int i = 0; i < n; i++)
        {
            int h, m, s;
            int entime;
            int detime;

            scanf("%d:%d:%d", &h, &m, &s);
            retime[h * 60 * 60 + m * 60 + s]++;
            scanf("%d:%d:%d", &h, &m, &s);
            retime[h * 60 * 60 + m * 60 + s]--;
        }

        for (int i = 1; i < 360000; i++)
        {
            retime[i] += retime[i - 1];
        }

        ans = *max_element(retime.begin(), retime.end());

        cout << ans << endl;

        cin >> n;
    }
}

C++: #include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
//int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	int n;
	const int MAX=10010;
	while(1){
		int ans_1[MAX],ans_2[MAX],cnt=0,ans=0;
		cin>>n;
		if(n==0)break;
		string s;
		rep(i,0,n){
			cin>>s;
			ans_1[i]=(int)((s[0]-'0')*10+s[1]-'0')*3600+(int)((s[3]-'0')*10+s[4]-'0')*60+(int)((s[6]-'0')*10+s[7]-'0');
			cin>>s;
			ans_2[i]==(int)((s[0]-'0')*10+s[1]-'0')*3600+(int)((s[3]-'0')*10+s[4]-'0')*60+(int)((s[6]-'0')*10+s[7]-'0');
		}
		int a[90000];
		rep(i,0,n)a[ans_1[i]]++,a[ans_2[i]]--;
		rep(i,0,90000)if(a[i]!=0)cnt+=a[i],ans=max(ans,cnt);
		print(ans);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
using namespace std;

typedef ostringstream oss;
typedef istringstream iss;

typedef vector<int> vi;
typedef vector< vi > vvi;

typedef long L;
typedef long long LL;

const int DAY_OF_SECOND = 24 * 60 * 60;

// 複数文字split
vector<string> split(const string &str, const string &delim = " ") {
	int start = 0, pos;
	vector<string> result;
	
	while ( (pos = str.find_first_of( delim, start) ) != string::npos ) {
		if (pos - start != 0)
			result.push_back( str.substr( start, pos - start) );
		start = pos + 1;
	}

	return result;
}

LL toSecond(int h, int m, int s) {
	return (LL)h * 24 * 60 + (LL)m * 60 + s;
}



int main(void) {
	int N;
	while (cin >> N, N) {
		vi time(DAY_OF_SECOND, 0);

		for (int i = 0; i < N; i++) {
			int h, m, s;
			char buf;
			cin >> h >> buf >> m >> buf >> s;
			LL start = toSecond(h, m, s);
			cin >> h >> buf >> m >> buf >> s;
			LL end = toSecond(h, m, s);

			for (LL i = start; i < end; i++) {
				time[i]++;
			}
		}

		cout << *(max_element(time.begin(), time.end())) << endl;
	}

	return 0;
}