Patchworking singular algebraic curves I