S.Korean shares post best quarter in 30 years on chip rally