#include "puzutl.h"
YesNo used[10];
int main( int argc, cstring argv[])
{
int64 mind = 10000000000L, maxd = 0;
for( int a=0; a< 10; a++) {
used[a] = YES;
for( int b=0; b< 10; b++) {
if( used[b]) continue;
used[b] = YES;
for( int c=0; c< 10; c++) {
if( used[c]) continue;
used[c] = YES;
for( int d=0; d< 10; d++) {
if( used[d]) continue;
used[d] = YES;
for( int e=0; e< 10; e++) {
if( used[e]) continue;
used[e] = YES;
for( int f=0; f< 10; f++) {
if( used[f]) continue;
used[f] = YES;
for( int g=0; g< 10; g++) {
if( used[g]) continue;
used[g] = YES;
for( int h=0; h< 10; h++) {
if( used[h]) continue;
used[h] = YES;
for( int i=0; i< 10; i++) {
if( used[i]) continue;
used[i] = YES;
for( int j=0; j< 10; j++) {
if( used[j]) continue;
used[j] = YES;
int Y,M,D,H,MI;
Y = a*10 + b;
M = c*10 + d;
D = e*10 + f;
H = g*10 + h;
MI = i*10 + j;
if( M <= 12 && D <= 31 && H <= 23 && MI <= 59) {
int64 x = (int64)Y * 100000000L + M * 1000000L + D * 10000 + H * 100 + MI;
if( x < mind) mind = x;
if( x > maxd) maxd = x;
}
used[j] = NO;
}
used[i] = NO;
}
used[h] = NO;
}
used[g] = NO;
}
used[f] = NO;
}
used[e] = NO;
}
used[d] = NO;
}
used[c] = NO;
}
used[b] = NO;
}
used[a] = NO;
}
ps( "mind = %I64d\n", mind);
ps( "maxd = %I64d\n", maxd);
return 0;
}