solve the small case for fair and square problem