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 <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 SECOND_OF_DAY = 24 * 60 * 60;

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

int main(void) {
	int N;
	while (cin >> N, N) {
		vi time(SECOND_OF_DAY, 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;
}

C++: #pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

void chmax(ll& x, ll y) {
    if (x < y) x = y;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);


    while(1){
        int n; cin >> n;

        if (n == 0) break;
        vector<int> s(250100, 0);

        REP(i, n) {
            string l, r; cin >> l >> r;

            int li = 0, ri = 0;
            REP(j, 8) {
                if (j == 2 || j == 5) continue;
                li *= 10;
                li += l[j] - '0';

                ri *= 10;
                ri += r[j] - '0';
            }

            s[li]++;
            s[ri]--;
        }

        FOR(i, 1, s.size()) s[i] += s[i - 1];

        print(*max_element(ALL(s)));
    }

}

C++: #include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    while (1)
    {
        cin >> n;
        if (n == 0)
            break;
        typedef pair<string, string> SS;
        vector<SS> S(n);
        rep(i, n) cin >> S[i].first >> S[i].second;
        sort(all(S));
        vector<int> sh(n), sm(n), ss(n), gh(n), gm(n), gs(n);
        rep(i, n)
        {
            string s = S[i].first, t = S[i].second;
            sh[i] = (s[0] - '0') * 10 + s[1] - '0';
            sm[i] = (s[3] - '0') * 10 + s[4] - '0';
            ss[i] = (s[6] - '0') * 10 + s[7] - '0';
            gh[i] = (t[0] - '0') * 10 + t[1] - '0';
            gm[i] = (t[3] - '0') * 10 + t[4] - '0';
            gs[i] = (t[6] - '0') * 10 + t[7] - '0';
        }
        vector<int> h, m, s;
        rep(i, n)
        {
            bool f = false;
            int pos;
            rep(j, h.size())
            {
                if (h[j] > sh[i])
                    continue;
                if (h[j] == sh[i] && m[j] > sm[i])
                    continue;
                if (h[j] == sh[i] && m[j] == sm[i] && s[j] > ss[i])
                    continue;
                f = true;
                pos = j;
            }
            if (!f)
            {
                h.push_back(gh[i]);
                m.push_back(gm[i]);
                s.push_back(gs[i]);
            }
            else
            {
                h[pos] = gh[i];
                m[pos] = gm[i];
                s[pos] = gs[i];
            }
        }
        cout << h.size() << endl;
    }
}