This invention is intended to enhance and improve the resistance of a single- or double-stranded nucleic acid fragment comprising a base sequence of a functional nucleic acid to degradation by nucleolytic enzymes in a simple and cost-effective manner. The single- or double-stranded nucleic acid fragment comprises, ligated to at least one end thereof, hairpin-shaped DNA comprising: (A) a nucleic acid region comprising 2 to 5 arbitrary nucleotides; (B) a nucleic acid region comprising a "gna" or "gnna" base sequence, wherein each "n" represents "g", "t", "a", or "c", a base analogue, or a modified base; and (C) a nucleic acid region comprising a base sequence complementary to the nucleic acid region (A), sequentially from the 5' end toward the 3' end.