Problem A of GCJ 2014 round 1B
Problem B (small) of GCJ 2014 round 1B