Здесь решение очень похожей задачи https://www.google.com/search?q=%D0%B6%D0%B5%D1%81%D1%82+%D0%BE%D1%82%D0%B2%D0%B0%D0%BB%D0%B8&tbm=isch&ved=2ahUKEwi03sGXtJj-AhVUsyoKHTi3AKUQ2-cCegQIABAC&oq=%D0%B6%D0%B5%D1%81%D1%82+%D0%BE%D1%82%D0%B2%D0%B0%D0%BB%D0%B8&gs_lcp=ChJtb2JpbGUtZ3dzLXdpei1pbWcQAzoFCCkQogQ6AggpOgQIABADOgcIABCKBRBDOggIABCABBCxAzoFCAAQgAQ6BQgAEKIEUABYxjZgmUhoAHAAeAGAAZ0RiAHxS5IBETItMS4xLjAuMS4wLjUuMC4xmAEAoAEBsAEDwAEB&sclient=mobile-gws-wiz-img&ei=-GEwZLSCONTmqgG47oKoCg&bih=604&biw=360&prmd=inv#imgrc=S05jbXHtQTwZ8M