When you exit passport the 50s lounge is closer, but this lounge might be a bit further from the UA gate if it's in the higher 30s. If you plan to go to ANA and then stop at UA, I would go to the 50s. (I.e. turn left after passport.)
BTW, which ANA F lounge is better? In the 50s it's on the same level as the business lounge (I think?) but over in the 40s you go up one level versus going down to the business lounge.