As I said, I can't find a simpler and more readable way to write it. I already thought of most of these ways, but I think using goto in this case is just more readable (at least more than all of these options).
When I was in school, they said never use goto for any reason, you can always do without them and they're evil. I know why they teach you this, because if you don't use gotos properly your code turns into spaghetti. I don't get why they don't teach you the proper way to use gotos, though, that seems kinda wak.
The moment I stepped into the professional world, I was writing these nested for loops and everyone was all "what is this I can't even." They told me to use gotos to make the code more readable. I spit hot fire back "what if I write it in a function and use multiple returns, yo?" and they were like "you can do that, cuz, but I'd rather you just use gotos."
If you aren't allowed to use gotos, then that's silly, but I guess you aren't. The next best thing is multiple return statements, and after that you have to use the Nested Loops Of Sadness™ (NLOS).