Measurement of relative branching fractions for D+→K−K+K+ and Ds+→π−π+π+ decays