# [K (ngn/k)], 50 bytes

    {$[|//^r:2#',/0N 2#/:2^"o~"?"P"\x^"_";`error;+/r]}

[Try it online!][TIO-k6aji03p]

[K (ngn/k)]: https://bitbucket.org/ngn/k
[TIO-k6aji03p]: https://tio.run/##NYyxCsIwEEB3vyJcBRWVaMbc4B9I9ppcHIxISw@ODina/HpU0OEtD97r9sN9qDXZ57J9aR3Emma104ezMo22JgAXOIGDSw5AgPEmwoJbLX6u4zeaitikMkbucB3T9dFjxgll4@fF2AIRF/ehMOBRGf9zVJjcf@frGw "K (ngn/k) – Try It Online"