Atomic-scale structure and surface reactions of water and ammonia on ruthenium