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 <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string str("0123456789");
	int n;
	while(cin>>n){
		if(n==0) break;
		string s;
		int a[n][2];
		for(int i=0;i<n;i++){
			a[i][0]=0;
			a[i][1]=0;
			cin>>s;
			for(int j=0;j<10;j++){
				if(s[0]==str[j]){
					a[i][0]=a[i][0]+60*60*10*j;
				}
				if(s[1]==str[j]){
					a[i][0]=a[i][0]+60*60*j;
				}
				if(s[3]==str[j]){
					a[i][0]=a[i][0]+60*10*j;
				}
				if(s[4]==str[j]){
					a[i][0]=a[i][0]+60*j;
				}
				if(s[6]==str[j]){
					a[i][0]=a[i][0]+10*j;
				}
				if(s[7]==str[j]){
					a[i][0]=a[i][0]+j;
				}
			}
			cin>>s;
			for(int j=0;j<10;j++){
				if(s[0]==str[j]){
					a[i][1]=a[i][1]+60*60*10*j;
				}
				if(s[1]==str[j]){
					a[i][1]=a[i][1]+60*60*j;
				}
				if(s[3]==str[j]){
					a[i][1]=a[i][1]+60*10*j;
				}
				if(s[4]==str[j]){
					a[i][1]=a[i][1]+60*j;
				}
				if(s[6]==str[j]){
					a[i][1]=a[i][1]+10*j;
				}
				if(s[7]==str[j]){
					a[i][1]=a[i][1]+j;
				}
			}
		}
		int ct=0,iru=0;
		for(int i=0;i<86400;i++){
			for(int j=0;j<n;j++){
				if(a[j][0]==i){
					ct++;
				}
				else if(a[j][1]==i){
					ct--;
				}
			}
			iru=max(iru,ct);
		}
		cout<<iru<<endl;
	}
    return 0;
}

C++: #include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int n;

int main(){
	while(cin>>n&&n){
		priority_queue<pair<int,int> > q;
		int h1,m1,s1,h2,m2,s2,ans=0,cur=0;
		char c;
		rep(i,n){
			cin>>h1>>c>>m1>>c>>s1>>h2>>c>>m2>>c>>s2;
			q.push(make_pair(h1*3600+m1*60+s1,1));
			q.push(make_pair(h2*3600+m2*60+s2,0));
		}
		while(!q.empty()){
			if(q.top().second)cur--;
			else cur++;
			q.pop();
			ans=max(ans,cur);
		}
		cout<<ans<<endl;
	}
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int fmt(string s)
{
    int ret = 0;
    ret += (s[0] - '0') * 36000;
    ret += (s[1] - '0') * 3600;
    ret += (s[3] - '0') * 600;
    ret += (s[4] - '0') * 60;
    ret += (s[6] - '0') * 10;
    ret += (s[7] - '0') * 1;
    return ret;
}

int main()
{
    while (true)
    {
        int n;
        cin >> n;
        if (n == 0)
        {
            return 0;
        }
        vector<int> times(100000, 0);
        for (int i = 0; i < n; i++)
        {
            string s1, s2;
            cin >> s1 >> s2;
            int st = fmt(s1), fin = fmt(s2);
            times[st]++;
            times[fin]--;
        }
        for (int i = 0; i < times.size() - 1; i++)
        {
            times[i + 1] += times[i];
        }
        int ans = 0;
        for (int i = 0; i < times.size(); i++)
        {
            ans = max(ans, times[i]);
        }
        cout << ans << endl;
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> P;
static const int INF=1<<24;

int main(){
	string s;
	int n;
	while(cin>>n,n){
		int a[240010]={0};
		
		char tmp;
		rep(i,n){
			stringstream ss1,ss2;
			int t1=0,t2=0;
			cin>>s;
			//cout<<s<<endl;
			ss1<<s[0]<<s[1]<<s[3]<<s[4]<<s[6]<<s[7];
			ss1>>t1;
			cin>>s;
			ss2<<s[0]<<s[1]<<s[3]<<s[4]<<s[6]<<s[7];
			ss2>>t2;
			//cout<<t1<<" "<<t2<<endl;
			for(int i=t1;i<t2;i++){
				a[i]++;
			}
		}
		int res=0;
		rep(i,240001){
			res=max(res,a[i]);
		}
		cout<<res<<endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int ctoi(char c1, char c2) {
  return (c1 - '0') * 10 + (c2 - '0');
}

int totime(int h, int m, int s) {
  return h * 3600 + m * 60 + s;
}

int solve(int n) {
  int imos[100000] = {};
  for (int i = 0; i < n; i++) {
    std::string b, e;
    cin >> b >> e;
    int begin_i = totime(ctoi(b[0], b[1]), ctoi(b[3], b[4]), ctoi(b[6], b[7]));
    int end_i   = totime(ctoi(e[0], e[1]), ctoi(e[3], e[4]), ctoi(e[6], e[7]));
    imos[begin_i]++;
    imos[end_i]--;
  }
  int cum    = imos[0];
  int result = 0;
  for (int i = 1; i < 100000; i++) {
    cum += imos[i];
    result = std::max(result, cum);
  }
  return result;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  while (1) {
    cin >> n;
    if (n == 0) {
      break;
    }
    cout << solve(n) << endl;
  }

  return 0;
}