Soln to lucky tickets problem.