Standings.
(All scenarios based on the Bills beating the Steelers)
If the Dolphins win, they'll go to the Ravens since they will be the lowest seed, and the Bills will get the winner of the Texans/Browns.
If the Chiefs win, they will come to Buffalo and the winner of the Texans/Browns will go to the Ravens.