Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func swap(ints []int, i, j int) {
	ints[i], ints[j] = ints[j], ints[i]
}

func main() {
	w := nextInt()
	// println(w)
	nums := make([]int, w)
	for i := range nums {
		nums[i] = i+1
	}
	n := nextInt()
	// println(n)
	for i := 0; i < n; i++ {
		info := nextString()
		// println(info)
		infos := strings.Split(info, ",")
		a, _ := strconv.Atoi(infos[0])
		b, _ := strconv.Atoi(infos[1])
		swap(nums, a-1, b-1)
	}
	for _, v := range nums {
		fmt.Println(v)
	}
}

C++: #include <iostream>
#include <vector>
#include <string>

using namespace std;

int swap(int nowAt, int a, int b) {
    if (a == nowAt) {
        return b;
    }
    if (b == nowAt) {
        return a;
    }

    return nowAt;
}

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main() {
    int w, n, i, ii, nowAt;

    cin >> w >> n;

    int results[w];

    // ルートの読み込み
    int routes[n][2];
    for (i = 0; i < n; i++) {
        string buffer;
        cin >> buffer;

        vector<string> splitted = split(buffer, ',');
        routes[i][0] = stoi(splitted[0]);
        routes[i][1] = stoi(splitted[1]);
        vector<string>().swap(splitted); // メモリの解放
    }

    // それぞれあみだくじをやる
    for (i = 0; i < w; i++) {
        nowAt = i+1; // 最初の位置

        // あみだの全節を通る
        for (ii = 0; ii < n; ii++) {
            nowAt = swap(nowAt, routes[ii][0], routes[ii][1]);
        }

        results[nowAt-1] = i + 1;
    }

    for(int goal : results) cout << goal << endl;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;

class Amidakuji{

public:
	int W;
	vector<int> array;//????´?1???????????????
	Amidakuji(int w);
	void Swap(int x,int y);
	void call();
};

//????????????????????????????????????
Amidakuji::Amidakuji(int w){

	for (int i = 0; i < w; i++){
		array.push_back(i+1);//[0,1,2,3,4]={1,2,3,4,5}
	}
	
	W = w;

}

void Amidakuji::Swap(int x,int y){

	//???????????£????????????array[]???????????????
	//int?????§???????????£????????§char???int?????????????????????-48;
	
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	

}

void Amidakuji::call(){

	for (int i = 0; i<W; i++){
		cout << array[i] << endl;
	}

}

int main(){


	int w, n,loc,a,b,length;
	string text,str_a,str_b,str_v;
	

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);

			length=(int)text.length();
			//????????¶?????§??????10,2??????????????¨??????{1,0,,,2}??????????????¢????????£?????????????????§??????????????????????????????????????????

			//?????????????????????????????????????????????????????§?????????????????£?????????????????\????????????????????£???
			loc=text.find(",", 0);
			str_a = text[0];
			for (int j = 1; j < loc; j++){
				str_v = text[j];
				str_a = str_a + str_v;

			}
			str_b = text[loc + 1];
			for (int j = loc + 2; j < length; j++){
				str_v = text[j];
				str_b = str_b + str_v;
			}

			
			a = stoi(str_a);
			b = stoi(str_b);


			if (a != 0 && b != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(a, b);
				a = b = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pb push_back

# define inOut(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
# define RESET(a) memset(a,0,sizeof(a))
# define MEMO(a) memset(a,-1,sizeof(a))
# define DEBUG puts("Debug-Has-Come-Until-Here")


typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	cin.tie(NULL);

	char dummy;
	int T, a,b, arr[35],i,n;
	for (i=1; i<=35; i++) arr[i] = i;
	
	scanf("%d", &n);
	scanf("%d", &T);
	while (T--){
		scanf("%d%c%d", &a,&dummy,&b);
		swap(arr[a], arr[b]);
	}
	for (i=1; i<=n; i++)printf("%d\n", arr[i]);
	
	return 0;
}

C++: #include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <sstream>

using hline_t = std::pair<unsigned, unsigned>;

int main(int argc, char const* argv[])
{
	unsigned w, n;
	std::cin >> w >> n ;
	std::vector<hline_t> hlines;
	for (int i = 0; i < n; i++) {
		std::string s;
		hline_t h;
		std::getline(std::cin, s, ',');
		h.first = std::stoi(s);
		std::getline(std::cin, s);
		h.second = std::stoi(s);
		hlines.push_back(h);
	}
	std::vector<unsigned> v(w + 1);
	{
		unsigned n = 0;
		std::generate(v.begin(), v.end(), [&n](){ return n++; });
	}

	for (auto var : hlines) {
		std::swap(v[var.first], v[var.second]);
	}
	std::for_each(v.begin() + 1, v.end(), [&](auto v){ std::cout << v << std::endl; });
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main() {
  int w, n;
  cin >> w >> n;
  int ans[n];

  for (int i=0; i<w; i++)
    ans[i] = i+1;
  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    int a = s[0] - '1';
    int b = s[2] - '1';
    swap(ans[a], ans[b]);
  }
  for (int i=0; i<w; i++)
    cout << ans[i] << endl;
}

C++: #include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;

int main(void){
    int w=0, n;
	cin>>w;
	vi x(w);
	for (int i=0; i<w; i++)
		x[i] = i+1;

	cin>>n;
	for (int i=0; i<n; i++){
		int a, b;
		char c;
		cin>>a>>c>>b;
		swap(x[a-1], x[b-1]);
	}

	for (int i=0; i<w; i++)
		cout<<x[i]<<endl;
    return 0;
}

C++: #include<iostream>
#include<vector>
 
int main()
{
    int w,n;
 
    char c;
 
    std::cin >> w >> n;
 
    std::vector<int> a(n);
 
    std::vector<int> b(n);
 
    std::vector<int> x(w);
 
    for(int i=0;i<n;++i)
    {
        std::cin >> a[i] >> c >> b[i];
    }
 
    for(int i=0;i<w;++i)
    {
        x[i]=i+1;
    }
 
    for(int i=0;i<n;++i)
    {
        int temp = x[a[i]-1];
 
        x[a[i]-1]=x[b[i]-1];
 
        x[b[i]-1]=temp;
    }
 
    for(int i=0;i<w;++i)
    {
        std::cout << x[i] << '\n';
    }
}

C++: #include<stdio.h>
int main(void){
	int w,n,x,y,temp;
	int a[31];
	char str[7];
	for(int i = 0; i < 31; i++){
		a[i] = i;
	}
	scanf("%d %d",&w,&n);
	for(int i = 0; i < n; i++){
		getline(str);
		if(str[3] == ',')
			str[3] = ' ';
		else
			str[2] = ' ';
		sscanf(str,"%d %d",&x,&y);
		temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

	for(int i = 0; i < w; i++){
		printf("%d\n",&a[i + 1];
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.dl", "r", stdin);
	string str = "";
	string res = "";
	int w;
	int n;

	getline (cin, str );
	stringstream ssw(str);
	ssw >> w;

	vector <int> Aj (w, 0);
	int i;
	for (i = 0; i < w; ++i){
		Aj[i] = i;
	} // end for
			
	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	for (i = 0; i < n; ++i){
		getline (cin, str );
		int a,b;
		str = str.replace(str.find(','), 1, " ");

		stringstream ss(str);
		ss >> a >> b;
//		cout << "a: " << a << " b: " << b << endl;
		swap(Aj[a-1], Aj[b-1]);
	} // end for

	for (i = 0; i < w; ++i){
		cout << (Aj[i] + 1) << endl;	
	} // end for
	
	return 0;
}