Gap beats expectations as Q1 profit climbs 40%