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<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;

void swap(int* a, int* b) {

	int work;

	work = *a;
	*a = *b;
	*b = work;
}

int main() {

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

	int a[30];
	for (int i = 0; i < 30; i++)a[i] = i + 1;
	int x, y;
	char c;
	for (int i = 0; i < n; i++) {
		cin >> x >> c >> y;

		swap(&a[x - 1], &a[y - 1]);
	}

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

	//system("pause");
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<algorithm>
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;
	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 < (signed) 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 <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int w,n;
int a,b;
int l[30];

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

        return 0;

}

C++: #include<iostream>

using namespace std;
 
int main() {
	
    int L[30];
    for(int i=0;i<30;i++)
	L[i]= i + 1;
	
    int a, b;
    cin >> a >> b;
    for(int i=0;i<b;i++){
    	
        int c,d;
        cin >> c >> d;
        
        int s = L[c-1];
        L[c-1] = L[d-1];
        L[d-1] = s;
        
    }
    for(int i=0;i<a;i++)
	cout << L[i] << "\n";
	
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int w,n,a,b,ans[30];
cin >> w >> n;
for(int i=0;i<w;i++)ans[i]=i+1;
for(int i=0;i<n;i++){
cin >> a >> b;
swap(ans[a-1],ans[b-1]);
}
for(int i=0;i<w;i++)printf("%d\n",ans[i]);
return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<memory>
#include<array>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
  int w, n;
  int a, b;
  char c;
  
  array<int, 30> kuji;
  
  cin >> w;
  cin >> n;

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

  for ( int i = 0; i < w; i++ )
    cout << kuji[i] << endl;

  return 0;
}

C++: #include <cstdio>
#define LOOP(index,times) for(int index=0;index<times;index++)
using namespace std;

int main(){

int w,n,a,b,temp;
int* num;

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

num=new int[w];

LOOP(i,w)
	num[i]=i+1;

LOOP(i,n){
	scanf("%d,%d",&a,&b);
	temp=num[a-1];
	num[a-1]=num[b-1];
	num[b-1]=temp;
}

LOOP(i,w)
	printf("%d\n",num[i]);

delete [] num;
return 0;		
}

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

using namespace std;

int main() {
	int w, n;
	int a, b;
	cin >> w >> n;
	int *W = new int[w];
	for (int i = 0; i < w; i++)
		W[i] = i + 1;

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

	for (int i = 0; i < w; i++)
		cout << W[i] << endl;

	delete[] W;
	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=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();
	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;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int w,n;
    cin>>w>>n;
    int na[31];
    for(int i=1;i<=w;++i){
        na[i]=i;
    }
    for(int i=0;i<n;++i){
        int a,b;
        cin>>a;
        cin.ignore();
        cin>>b;
        swap(na[a],na[b]);
    }
    for(int i=1;i<=w;++i){
        cout<<na[i]<<endl;
    }
    return 0;
}