Wayfair posts first quarterly profit in 4 years