strs = gets.chomp.split("") a = gets.chomp.map(&:to_i) tmp = strs[a[0]] strs[a[0]] = strs[a[1]] strs[a[1]] = tmp puts strs.join