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() {
	ios_base::sync_with_stdio( false );

	int w, n;
	cin >> w >> n;

	vector<pair<int, int>> hl( n );

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

		hl[i] = { a, b };
	}

	vector<int> vl( w+1 );

	for( int i = 1; i <= w; ++i ) {
		int x = i;

		for( int j = 0; j < n; ++j ) {
			if( x == hl[j].first ) {
				x = hl[j].second;
			}
			else if( x == hl[j].second ) {
				x = hl[j].first;
			}
		}

		vl[x] = i;
	}

	for( int i = 1; i <= w; ++i ) {
		cout << vl[i] << '\n';
	}
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int n , w , i , j , a , b;
	int number[40] ;
	cin >> w ;
	cin >> n;
	for( i=1 ; i<=n ; i++ ){
		scanf( "%d,%d" , &a , &b );
		int x = number[a];
		number[a] = number[b];
		number[b] = x ;
	}
	for( i=1 ; i<=w ; i++ )
		cout << number[i] << endl;
}

C++: 
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int w;
	int amida[31];
	int n;
	char aaa;
	cin >> w >> n;
	int a, b, keep;
	for (int i = 1; i <= w; i++) {
		amida[i] = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> a >>aaa>> b;
		keep = amida[a];
		amida[a] = amida[b];
		amida[b] = keep;
	}
	for (int i = 1; i <= w; i++) {
		cout << amida[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include<cstdio>
using namespace std;
int main (){
	int w,N,d[30],c[30];
	int a,b;

	cin>>w>>N;
	for(int j=1;j<=w;j++){
		d[j]=j;
		c[j]=d[j];
	}
	for(int i=0;i<N;i++){
        scanf("%d,%d",&a,&b);
		d[a]=d[b];
		d[b]=c[a];
		c[a]=d[a];
	}
	for(int k=1;k<=w;k++){
	cout<<d[k]<<endl;
	}

	return 0;
}

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

int main()
{
  int w,n;
  int c[50]={0};
  int a,b;
  //  int temp;

  scanf("%d",&w);
  scanf("%d",&n);

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

  for(int i=0; i<n; i++){
    scanf("%d,%d", &a,&b);
    swap(c[a], c[b]);
  }

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

C++: #include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<sstream>
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 stoi(string str){
	int ret;
	stringstream ss;
	ss << str;
	ss >> ret;
	return ret;
}

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++: 
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)

int main(void){
    CIN_NO_SYNC;

    int w,n;
    cin >> w >> n;
    int p[31];
    REP(i, w) p[i+1] = i+1;

    REP(i, n){
        int a,b; char c;
        cin >> a >> c >> b;
        swap(p[a], p[b]);
    }
    REP(i, w) printf("%d\n", p[i+1]);

    return 0;
}

C++: #include<iostream>

int listen_lineCount();
void listen_path(int &from,int &to);

class Lots
{
private:
	int *start_goal;
	int verLineNum;
public:
	Lots(const int lineCount);
	~Lots();
	
	void draw_line(const int from,const int to);
	void echo_goalNums();
};

//-------------------------main--------------------------------

int main()
{
	int ver_lineCount=listen_lineCount();
	Lots *inst_lot;
	inst_lot=new Lots(ver_lineCount);
	
	int hor_lineCount=listen_lineCount();
	
	int from,to;
	for(int roop=0;roop<hor_lineCount;roop++)
	{
		listen_path(from,to);
		inst_lot->draw_line(from,to);
	}
	
	inst_lot->echo_goalNums();
	
	delete inst_lot;
	return 0;
}

//--------------------------------------------------------------

Lots::Lots(const int lineCount)
{
	verLineNum=lineCount;
	start_goal=new int(lineCount+1);
	
	for(int roop=1;roop<=lineCount;roop++)
	{
		start_goal[roop]=roop;
	}
}

Lots::~Lots()
{
	delete [] start_goal;
}

void Lots::draw_line(const int from,const int to)
{
	int swap=start_goal[from];
	start_goal[from]=start_goal[to];
	start_goal[to]=swap;
}

void Lots::echo_goalNums()
{
	using namespace std;
	
	for(int roop=1;roop<=verLineNum;roop++)
	{
		cout<<start_goal[roop]<<endl;
	}
}


int listen_lineCount()
{
	using namespace std;
	
	int lineCount;
	cin>>lineCount;
	
	return lineCount;
}

void listen_path(int &from,int &to)
{
	using namespace std;
	
	char delim;//カンマ区切り
	
	cin>>from>>delim>>to;
}