Wales need a bonus point win to avoid the wooden spoon.
They need a bonus point win
and one of Ireland or Italy not to get a bonus point and they need to overturn the points difference to that team - 35 or 37 points respectively. Beating Italy by 19 points without Italy scoring four tries will do it.
If they fail to stop Italy from scoring four tries or from getting closer than 19 points, they have to hope Scotland beat Ireland by a big enough margin and stop Ireland from getting four tries.