Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	n := nextInt()

	numbers := make([]int, w+1)
	for i := 1; i <= w; i++ {
		numbers[i] = i
	}

	for i := 0; i < n; i++ {
		line := nextString()
		words := strings.Split(line, ",")
		a, _ := strconv.Atoi(words[0])
		b, _ := strconv.Atoi(words[1])

		numbers[a], numbers[b] = numbers[b], numbers[a]
	}

	for i := 1; i <= w; i++ {
		fmt.Println(numbers[i])
	}
}

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;
}

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

#include "stdafx.h"
#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] = stoi(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;
}