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 <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int table[100000];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while(cin >> n,n){
		rep(i,100000) table[i] = 0;
		rep(i,n){
			char t;
			int a,b,c,d,e,f;
			cin >> a >> t >> b >> t >> c >> d >> t >> e >> t >> f;
			c += a*3600+b*60;
			f += d*3600+e*60;
			table[c]++;
			table[f-1]--;
		}
		for(int i = 1; i < 100000; i++) table[i] += table[i-1];
		int ans = 0;
		rep(i,100000) ans = max(ans,table[i]);
		cout << ans << endl;
	}
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vpii v(n);
    rep(i, n) {
      int h, m, d;
      char gomi;
      cin >> h >> gomi >> m >> gomi >> d;
      int l = h * 3600 + m * 60 + d;
      cin >> h >> gomi >> m >> gomi >> d;
      int r   = h * 3600 + m * 60 + d;
      v[i].fi = l;
      v[i].se = r;
    }
    priority_queue<int, vector<int>, greater<int>> q;
    q.push(v[0].se);
    loop(i, 1, n) {
      if (q.top() <= v[i].fi) q.pop();
      q.push(v[i].se);
    }
    cout << q.size() << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
	int n;
	while(cin >> n,n){
		int bh[n],bm[n],bs[n],eh[n],em[n],es[n];
		for(int i=0;i<n;i++)
		scanf("%d:%d:%d %d:%d:%d",&bh[i],&bm[i],&bs[i],&eh[i],&em[i],&es[i]);
		int count=0,m=1;
		for(int i=0;i<n;i++){
			for(int j=1;i+j<n;j++){
				if(((eh[i]==bh[i+j])&&(em[i]==bm[i+j])&&(es[i]>bs[i+j]))||((eh[i]==bh[i+j])&&(em[i]>bm[i+j]))||eh[i]>bh[i+j]){
					count++;
				}
				else{
				i=j;
				break;
				}
			}
			m=max(m,count);
		}
		cout << m << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
using namespace std;

int convert(string s){
	int h=(s[0]-'0')*10+(s[1]-'0');
	int m=(s[3]-'0')*10+(s[4]-'0');
	int t=(s[6]-'0')*10+(s[7]-'0');
	return h*3600+m*60+t;
}

class range{
public:
	int left,right;
	range(int left,int right):left(left),right(right){}
	range(){};
};

bool is_connect(range a,range b){
	if(b.left<=a.right && a.right<=b.right) return true;
	if(b.left<=a.left && a.left<=b.right) return true;
	return false;
}


int main()
{
	int n;
	while(cin>> n && n!=0){
		vector<range> V(n);
		for(int i=0;i<n;i++){
			string s,t;cin>>s>>t;
			V[i].left=convert(s);
			V[i].right=convert(t);
		}


		int ans=1;
		for(int i=0;i<n;i++){
			int count=1;
			for(int j=0;j<n;j++){
				if(i==j) continue;
				if(is_connect(V[i],V[j])) count++;
			}
			ans=max(ans,count);
		}
		cout<<ans<<endl;
	}
	return 0;
}