Mobility Quest Interview Question

Matrix problem which is much confusing