UVa problem: Chess - Recognize the patterns