AMS has Yotel but it can be expensive. Sleeper chairs look good and are in a dark quiet area. MAD also has a terminal hotel but also very expensive. If you opt for Madrid you could check whether you can pay with points - if you have any. E.g. Hilton.
There's quite a few option for a same day so maybe bite the bullet and pay a bit more for a better layover?