There are guests and sofas, numbered from to and from to , respectively. Guest has size , and sofa has capacity . Each sofa can hold at most one guest, and guest can sit on sofa only if .
Initially, guest is sitting on sofa and wants to end up on sofa . Both arrangements are valid: the guests occupy distinct sofas, and every guest fits on their sofa.
In one move, choose a guest and move them to the empty sofa, provided that they fit on it. Their previous sofa becomes empty.
Find the minimum number of moves needed to reach the desired arrangement. If it is impossible, output .