PLEASE NOTE!

The table indicates NAM not NM. As the question gives you a 40kts headwind, you have to apply the formula NM=NAM*GS/TAS.
therefore, NM=844*120/160=633NM