Added Java model to use on solving problems. Heavily based on Egor and Petr submissions on CodeForces.