Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

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

}

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 <iostream>
using namespace std;

const int max_w = 30;
int w[max_w];

void init(int n){
	for(int i=0;i<n;i++){
		w[i] = i+1;
	}
}
void swap(int a,int b)
{
	int tmp = w[a];
	w[a] = w[b];
	w[b] = tmp;
}
void show(int n)
{
	for(int i=0;i<n;i++){
		cout << w[i] << endl;
	}
}

int main()
{
	int w,n;
	int a,b;
	char c;

	while(cin >> w && cin >> n){
		init(w);
		for(int i=0;i<n;i++){
			cin >> a  >> c >> b;
			swap(a-1,b-1);
		}
		show(w);
	}
	return 0;
}

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

int main() {
	int w,n;
	
	cin >> w >> n;
	int a[30];
	for ( int i = 1; i <= 30; i++ )
		a[i - 1] = i;
	int ai,bi;
	for ( int i = 0; i < n; i++ ) {
		scanf ("%d,%d",&ai,&bi);
		swap ( a[ai-1],a[bi-1] );
	}
	for ( int i = 0; i < w; i++ )
		cout << a[i] << endl;
	
	return 0;
}

C++: #include<stdio.h>

int main(){
	int t[30];
	for(int i=0;i<30;i++)t[i]=i+1;
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int c,d;
		scanf("%d,%d",&c,&d);
		int s=t[c-1];
		t[c-1]=t[d-1];
		t[d-1]=s;
	}
	for(int i=0;i<a;i++)printf("%d\n",t[i]);
}

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

typedef pair<int,int> P;

int w,n;
P yoko;	//データは高さ昇順
int pos[32];	//縦棒iからスタートしたとき、今pos[i]番目の縦棒にいる。

int seach(int *p,int num,int size){
	for(int i = 0;i < size;i++){
		if(p[i] == num)
			return i;
	}
	return -1;
}
int main(){
	int i;
	cin >> w >> n;
	for(i = 1;i <= w;i++){
		pos[i] = i;
	}
	for(i = 0;i < n;i++){
		int t1,t2;
		scanf("%d,%d",&yoko.first,&yoko.second);
		t1 = seach(pos,yoko.first,w+1);t2 = seach(pos,yoko.second,w+1);
		//cout << pos[t1] << pos[t2] << endl;
		pos[t1] = yoko.second;
		pos[t2] = yoko.first;
		//cout << pos[t1] << pos[t2] << endl;
	}
	int sita[32];
	for(i = 1;i <= w;i++){
		sita[pos[i]] = i;
	}
	for(i = 1;i <= w;i++)
		cout << sita[i] << endl;
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int i,w,n,a,b,temp;
	int *amida;
	char comma;
	cin>>w>>n;
	amida=new int[w];
	for(i=0;i<w;i++){
		amida[i]=i+1;
	}
	while(n--){
		cin>>a>>comma>>b;
		temp=amida[a-1];
		amida[a-1]=amida[b-1];
		amida[b-1]=temp;
	}
	for(i=0;i<w;i++){
		cout<<amida[i]<<endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;
int data[40];
int main(){

	for(int i=0;i<40;i++)data[i]=i;
	int w;
	int n;
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		char tmp[3];
		cin>>tmp;
		int a=tmp[0]-'0';
		int b=tmp[2]-'0';
		for(int j=1;j<=w;j++){
			if(j==b){
				int tmp=data[a];
				data[a]=data[b];
				data[b]=tmp;
			}
		}
	}
	
	for(int i=1;i<=w;i++)cout<<data[i]<<endl;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;
int w;
int line[31][2];
int perm[31];

int main() {
	cin >> n;
	cin >> w;
	for (int i = 0; i < w; i++) {
		scanf("%d,%d", &line[i][0], &line[i][1]);
	}

	for (int i = 1; i <= n; i++) {
		int pt = i;
		for (int j = 0; j < w; j++) {
			if (line[j][0] == pt) pt = line[j][1];
			else if (line[j][1] == pt) pt = line[j][0];
		}
		perm[pt] = i;
	}

	for (int i = 1; i <= n; i++) {
		cout << perm[i] << endl;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

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

int main()
{
  int w,n;
  int c[]={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 <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int d[30];

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int W, N;
	scanf("%lld%lld", &W, &N);
	rep(i, W) d[i] = i + 1;
	rep(i, N) {
		int a, b;
		scanf("%lld,%lld", &a, &b);
		a--; b--;
		swap(d[a], d[b]);
	}

	rep(i, W) cout << d[i] << endl;
	return 0;
}

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

using namespace std;

int cell[31];

int main() {
    int w, n, a, b;

    for (int i = 1; i <= 30; i++) {
        cell[i] = i;
    }

    cin >> w >> n;

    while (n--) {
        int a, b;
        scanf("%d,%d", &a, &b);
        swap(cell[a], cell[b]);
    }

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

    return 0;
}