readlines.each {|l| is, s = l.split(' ') next puts is||'' unless s x = 0 is.split(',').each {|i| s.insert(i.to_i + x, ' ') x += 1 } puts s }