Study of hyperfragments produced in high energy interactions of pions and protons with emulsion nuclei