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 <bits/stdc++.h>
using namespace std;

int main()
{
	char c;
	int w, n;
	cin >> w >> n;
	vector<int> res(w);
	for (int i = 0; i < w; i++) {
		res[i] = i + 1;
	}
	for (int i = 0, a, b; i < n; i++) {
		cin >> a >> c >> b;
		swap(res[a - 1], res[b - 1]);
	}
	for (int i = 0; i < w; i++) {
		cout << res[i] << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void) {
	int w,n, a[30][2],i,c,no,rs[30];
	
	scanf("%d%d",&w,&n);
	for(i = 0; n > i; i++){
		scanf("%d",&a[i][0]);
		getchar();
		scanf("%d",&a[i][1]);
	}
	
	for(i = 1; w >= i; i++){
		no = i;
		for(c = 0; n > c; c++){
			if(a[c][0] == no) no = a[c][1];
			else if(a[c][1] == no) no = a[c][0];
		}
		rs[no-1] = i;
	}
	for(i = 0; w > i; i++){
		printf("%d\n",rs[i]);
	}
	
	return 0;
}

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

int main(void){
	int w,n,x,y,temp;
	int a[31];
	char c;
	string str;
	for(int i = 0; i < 31; i++){
		a[i] = i;
	}
	cin >> w >> n;
	for(int i = 0; i < n; i++){
		cin >> str;
		istringstream is(str);
		is >> x >> c >> y;
		temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

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

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

int main(){
  int w,n;
  int a[40];
  for(int i=0; i<40; i++){
    a[i] = i;
  }
  cin >> w >> n;
  for(int i=0; i<n; i++){
    int s,t;
    char c;
    cin >> s >> c >> t;
    swap(a[s],a[t]);
  }
  for(int i=1; i<=w; i++){
    cout << a[i] << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
//#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	int n, m; cin >> n >> m;
	vector<int> v(n);
	rep(i, n) v[i] = i + 1;
	rep(i, m) {
		string s; cin >> s;
		string s1, s2;
		bool flag = true;
		for (auto a : s) {
			if (a == ',') flag = !flag;
			else if (flag) {
				s1 = s1 + a;
			}
			else {
				s2 = s2 + a;
			}
		}
		int a, b;
		a = stoi(s1);
		b = stoi(s2);
		swap(v[a - 1], v[b - 1]);
	}
	for (auto a : v) {
		cout << a << endl;
	}
}

C++: #include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;

int sosuu(int n);

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

    }
    
}

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

int main() {
  int w, n;
  cin >> w >> n;
  vector<int> a(n), b(n);
  char c;
  for (int i = 0; i < n; ++i)
    cin >> a[i] >> c >> b[i];

  vector<int> ans(w + 1);
  for (int j = 1; j <= w; ++j)
    ans[j] = j;

  for (int i = 0; i < n; ++i)
    swap(ans[a[i]], ans[b[i]]);

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
typedef long long int LLI;
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n,m;
  char d;
  cin>>n>>m;
  vector<int>out(n);
  rep(i,n)out[i]=i+1;
  rep(i,m){
    int a,b;
    cin>>a>>d>>b;
    swap(out[a-1],out[b-1]);
  }
  rep(i,n)cout<<out[i]<<endl;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define INF 1<<25
#define LIM 1000000

using namespace std;

int bar[30];
int w, n;

int main()
{
	cin >> w >> n;
	
	FOR(i,0,w)
	{
		bar[i] = i+1;
	}
	
	FOR(i,0,n)
	{
		int a,b; char c;
		cin >> a >> c >> b;
		
		swap(bar[a-1], bar[b-1]);
	}
	
	FOR(i,0,w)
	{
		cout<<bar[i]<<endl;
	}
	
	
	return 0;
}

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;
	x -= 48;
	y -= 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;
	string text;

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);
			if (text[0] != 0 && text[2] != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(text[0], text[2]);
				text[0] = text[2] = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}


	return 0;
}

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

using namespace std;

void Swap(vector<int>& v, int index1, int index2) {
    int tmp = v[index1];
    v[index1] = v[index2];
    v[index2] = tmp;
}


int main() {
    int w;
    cin >> w;

    vector<int> v(w);
    for(int i = 0; i < v.size(); ++i) {
        v[i] = i + 1;
    }
    
    int n;
    cin >> n;

    for(int i = 0, a, b; i < n; ++i) {
        cin >> a;
        cin.ignore();
        cin >> b;

        Swap(v, a - 1, b - 1);
    }

    for(auto x : v) {
        cout << x << '\n';
    }

    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

int a[50],b[50];

int main(){

	int w,h;
	cin>>w>>h;
	for (int i = 0; i < h; i++)
	{
		char c;
		cin>>a[i]>>c>>b[i];
		a[i]--; b[i]--;
	}

	vector<int> v(w);
	for (int i = 0; i < w; i++)
	{
		v[i] = i+1;
	}

	for (int i = 0; i < h; i++)
	{
		swap(v[a[i]],v[b[i]]);
	}

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


	return 0;
}

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

using namespace std;

void change(int *, int *);

int main(void){
	int w,n;
	int p[31];
	int a, b;
	cin >> w;
	cin >> n;
	
	for(int i = 1; i <= w; i++){
		p[i] = i;
	}
	
	for(int j = 0; j < n; j++){
		scanf("%d,%d", &a, &b);
		change(&p[a], &p[b]);
		
	}
	for(int i = 1; i <= w; i++){
		cout << p[i] << endl;
	}
	return 0;
}

void change(int *x, int *y){
	int type = *x;
	*x = *y;
	*y = type;
}