Solution by Sergey Gogolev

Yandex.School.2013: 4-layout