How would someone obtain a civil service job under the Sung dynasty?

by passing an exam
by bribing the nobility
by proving a military background
by being related to an employee