program works for single test case provided by UVa