Mobility Quest interview question

Matrix problem which is much confusing