SPOJ Philosopher stone