Codeforces Beta Round #22 Problem BD