UVa 410 - Copied book algorithm