House votes to avert rail strike, impose deal on unions