You choose $u$ by which factor comes first on the page.
$u$ is the factor that improves when differentiated: a power that drops, a $\ln$ that disappears. If the new integral is worse than the original, the choice was wrong.
Next time: Check after one line; swap if it got uglier.