Codeforces Beta Round #19 Problem ABCD