Amazon sees strong profit in Q2, recovering from loss