Ford posts surprise quarterly profit on rising prices