Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

C++: #include <iostream>
#include<math.h>
#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;
	}

}

//???????????§?????????????????°?????????????????????????????§???????????????????????°??????????????¢??°
void Func(string str,char a){



};



int main(){


	int w, n,loc,a,b;
	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);

			//????????¶?????§??????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 < text.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;

int main() {
	ios :: sync_with_stdio(false);
	int p[31]; iota(p, p + 31, 0);
	int w, n; cin >> w >> n;
	while(n --) {
		int i, j; char c;
		cin >> i >> c >> j;
		swap(p[i], p[j]);
	}
	for(int i = 1; i <= w; i ++)
		cout << p[i] << '\n';
	return 0;
}

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



int main()
{

    int JumlahGarisVertikal;
    int JumlahGarisHorizontal;
    int DaftarAngka[30];
    int TukarNilai[30][2];

    cin >> JumlahGarisVertikal;
    cin >> JumlahGarisHorizontal;

    for(int x = 0 ; x < JumlahGarisVertikal; x++)
    {
        DaftarAngka[x] = x+1;
    }

    for(int y = 0; y < JumlahGarisHorizontal; y++)
    {
        scanf("%d,%d",&TukarNilai[y][0],&TukarNilai[y][1]);

        int temp = DaftarAngka[TukarNilai[y][0] - 1];
        DaftarAngka[TukarNilai[y][0] - 1] = DaftarAngka[TukarNilai[y][1] - 1];
        DaftarAngka[TukarNilai[y][1] - 1] = temp;
    }

    for(int z = 0; z < JumlahGarisVertikal; z++)
    {
        cout << DaftarAngka[z] << endl;
    }

}

C++: #include <iostream>

using namespace std;

int main()
{
    int w, n;
    char comma;
    int a, b;
    int ans[32];
    
    cin >> w >> n;
    for (int i = 1; i <= w; i++)
        ans[i] = i;

    for (int i = 0; i < n; i++) {
        cin >> a >> comma >> b;
        int tmp = ans[a];
        ans[a] = ans[b];
        ans[b] = tmp;
    }

    for (int i = 1; i <= w; i++)
        cout << ans[i] << endl;

    return 0;
}

C++: #include <stdio.h>

void swap(int *a, int *b){
int c=*a;
*a=*b;
*b=c;
return;
}

int main(void)
{
int w,n;
scanf("%d",&w);
int list[w];
scanf("%d",&n);
for(int i=0;i<n;i++){
int a,b;
scanf("%d,%d",&a,&b);
swap(list[a],list[b]);
}
for(int i=0;i<w;i++){
printf("%d\n",list[i]);
}
return 0;
}

C++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(ll a=0;a<t;a++)
int main()
{
	ll w, n;

	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	ll a[32];
	roop(i, 32) {
		a[i] = i + 1;
	}
	roop(i, n) {
		string s;
		cin >> s;
		string d[2];
		roop(i, s.length()) {
			if (s[i] == ',') { d[0] = s.substr(0, i); d[i] = s.substr(i + 1); break; }
		}
		ll swap[2];
		roop(i, 2) {
			swap[i] = stoll(d[i]);
		}
		ll before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	roop(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

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


int main(){
	int w , n;
	int d1 , d2;
	cin >> w >> n;
	vector<int> ans(w+1);
	for(int i=1 ; i<=w ; i++){
		ans[i]=i;
	}
	for(int i=0 ; i<n ; i++){
		scanf("%d,%d" , &d1 , &d2);
		swap(ans[d1] , ans[d2]);
	}
	for(int i=1 ; i<=w ; i++){
		cout << ans[i] << endl; 
	}
	return 0;
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    int ami[n+1];
    for(int i=0;i<n+1;i++){
        ami[i]=i;
    }
    for(int i=0;i<k;i++){
        int a,b;
        char c;
        cin>>a>>c>>b;
        swap(ami[a],ami[b]);
    }
    
    for(int i=1;i<n+1;i++){
        
        
        cout<<ami[i]<<endl;
    }
    
}

C++: #include<iostream>
#include<cstdlib>

using namespace std;

int main() {
	int i, j, l, num[31], w, n, a=0, b=0, c;
	char s[5], as[2], bs[2];
	
	cin >> w;
	for (i = 1; i <= w; i++) {
		num[i] = i;
	}
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s;
		for (j = 0; s[j] != ','; j++) {
			as[j] = s[j];
		}
		for (l=j; s[j + 1] != NULL; j++) {
			bs[j - l] = s[j + 1];
		}
		a = atoi(as);
		b = atoi(bs);
		c = num[a];
		num[a] = num[b];
		num[b] = c;
	}
	for (i = 1; i <= w; i++) {
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <iostream>

const int W_MAX = 30;
const int N_MAX = 30;

int w;
int n;
int a[N_MAX + 1];
int b[N_MAX + 1];
int out[W_MAX + 1];

void chenge(int *farst, int *second){
	int tmp;
	tmp = *farst;
	*farst = *second;
	*second = tmp;
}

int main(void){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	std::cin >> w;
	std::cin >> n;

	for(int i = 0; i <= w; i++){
		out[i] = i;
	}

	for(int i = 1; i <= n; i++){
		std::cin >> a[i] >> b[i];
		chenge(&out[a[i]], &out[b[i]]);
	}
	
	for(int i = 1; i <= w; i++){
		std::cout << out[i] << ' ';
	}

	std::cout << '/n';

	return 0;
}