hard test for problem 1196 (time limit exceeded)