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>
#define ADAY 86400
using namespace std;

int main(void){
  int n;
  while(cin >> n, n){
    vector < pair < int, int > > t;
    for(int i=0; i < n; i++){
      pair<int, int> tmp;
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.first = h * 3600 + m * 60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.second = h * 3600 + m * 60 + s;
      t.push_back(tmp);
    }

    int ans = 0, movin = 0, ind = 0;
    queue<int> q;
    for(int now=0; now < ADAY; now++){
      if(!q.empty() && now == q.front()){
        movin--;
        q.pop();
      }
      if(now == t[ind].first){
        q.push(t[ind].second);
        movin++;
        ind++;
        ans = max(ans, movin);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<map>
#define MAX 86400
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<string>
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,l,a;
	char s[20];
	P table[20000];
	while(cin>>n,n){
		int ma=0;
		for(int i=0;i<n;i++){
			cin>>s;
			l=atoi(s)*3600+atoi(&s[2])*60+atoi(&s[6]);
			table[i]=P(l,1);
			cin>>s;
			a=atoi(s)*3600+atoi(&s[2])*60+atoi(&s[6]);
			table[i+n]=P(a,0);
		}
		int now=0;
		sort(table,table+2*n);
		for(int i=0;i<2*n;i++){
			if(table[i].second)
			now++;
			else now--;
			ma=max(now,ma);
		}
		cout<<ma<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	while(cin>>n,n){
		vi dp(86400);
		int a,b,c,s,t;
		char q;
		rep(i,n){
			cin>>a>>q>>b>>q>>c;
			s=a*3600+b*60+c;
			cin>>a>>q>>b>>q>>c;
			t=a*3600+b*60+c;
			dp[s]++;
			dp[t]--;
		}
		rep(i,86400-1)dp[i+1]+=dp[i];
		int out=0;
		rep(i,86400)out=max(out,dp[i]);
		cout<<out<<endl;
	}
}

C++: #include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <list>


constexpr int INF = 1050000000;
constexpr int MOD = 1000000007;
constexpr long long LONGINF = 1005000000000000000;
using namespace std;

using ll = long long;
/*    UnionFind


class UnionFind {
private:
	std::vector<int> parent;
	std::vector<int> height;
	std::vector<int> m_size;

public:
	UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	void init(int size_) {
		parent.resize(size_);
		height.resize(size_, 0);
		m_size.resize(size_, 1);
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	int find(int x) {
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		int t = size(x) + size(y);
		m_size[x] = m_size[y] = t;
		if (height[x] < height[y]) parent[x] = y;
		else parent[y] = x;
		if (height[x] == height[y]) ++height[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		if (parent[x] == x) return m_size[x];
		return size(parent[x] = find(parent[x]));
	}
};


*/

int main() {
	

	while (1) {
		int n; cin >> n; if (n == 0) { return 0; }

		int imos[24 * 60 * 60 + 5] = {};

		for (int i = 0; i < n; i++) {
			char x;
			int a, b, c;
			cin >> a >> x >> b >> x >> c;
			imos[a * 3600 + b * 60 + c + 1] += 1;
			cin >> a >> x >> b >> x >> c;
			imos[a * 3600 + b * 60 + c + 1] -= 1;
		}

		int ans = 0;

		for (int i = 1; i < 24 * 60 * 60 + 5; i++) {
			imos[i] += imos[i - 1];
			ans = max(ans, imos[i]);
		}

		cout << ans << endl;

	}

}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
  int n;
  while(cin>>n,n){
    vector<pair<int,int> > timetable(n);
    for(int i=0;i<n;++i){
      int sh,sm,ss,eh,em,es;
      scanf("%d:%d:%d",&sh,&sm,&ss);
      scanf("%d:%d:%d",&eh,&em,&es);
      timetable[i]=make_pair(sh*3600+sm*60+ss,eh*3600+em*60+es);
    }
    int ans=0;
    for(int i=0,sti,eti;i<n;++i){
    	int cnt=1;
      sti=timetable[i].first;
      eti=timetable[i].second;
      for(int j=0,stj,etj;j<n;++j){
        if(i==j)continue;
        stj=timetable[j].first;
        etj=timetable[j].second;
        if((sti<stj&&stj<eti)||sti<etj&&etj<eti)++cnt;
      }
      ans=max(ans,cnt);
    }
    cout<<ans<<endl;
  }
  return 0;
}