Codeforces Round #221 Problem E Red and Black Tree