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>
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 <cstdio>
#include <algorithm>

using namespace std;

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

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

int set(int *arr, int n){
	for(int i = 1; i <= n; i++){
		arr[i] = i;
	}
}

int main(){
	int arr[50];
	int a, b;
	cin >> a >> b;
	set(arr, a);
	int x, y;
	for(int i = 0; i < b; i++){
		scanf("%d,%d", &x, &y);
		int temp = arr[x];
		arr[x] = arr[y];
		arr[y] = temp;
	}
	for(int i = 1; i <= a; i++){
		cout << arr[i] << endl;
	}
}

C++: #include<cstdio>
#include<algorithm>
int main(void){
    int i,w,n,a,b,*p;
    scanf("%d%d",&w,&n);
    p=new int[w];
    for(i=0;i<w;i++)p[i]=i+1;
    while(~scanf("%d,%d",&a,&b))std::swap(p[a-1],p[b-1]);
    for(i=0;i<w;i++) printf("%d\n",p[i]);
    return 0;
}

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

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

C++: #include <cstdio>

inline void swap(int array[], int a, int b){
	int c = array[a];
	array[a] = array[b];
	array[b] = c;
}

int main(){
	int array[50];
	int w,n,a,b;

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

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))



int main(){
	int n,q;
	cin >> n >> q;
	vector<int> A(n+1);
	FOR(i,1,n+1)A[i] = i;
	FOR(i,0,q){
		string s,x,y;
		cin >> s;
		bool k = false;
		for(char c:s){
			if(c==','){
				k = true;
				continue;
			}
			if(not k){
				x += c;
			}else{
				y += c;
			}
		}
		int a,b;
		a = stoi(x);
		b = stoi(y);
		swap(A[a],A[b]);
	}
	FOR(i,1,n+1){
		cout << A[i] << endl;
	}
}

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

#define swap(a,b) a^=b^=a^=b

using namespace std;


int main(){
    
    int w,n,a,b;
    cin >> w >> n;
    vector<int> ans;
    for(int i=0;i<=w;i++){
        ans.push_back(i);
    }

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

C++: #include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
typedef pair<int, int> P;

void solve()
{
	int w, n;
	cin >> w >> n;
	vector<P> vec(n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d,%d", &vec[i].first, &vec[i].second);
	}
	vector<int> pos(w);
	for(int i = 0; i < w; ++i)
	{
		int ans = i + 1;
		for(int j = 0; j < n; ++j)
		{
			if(vec[j].first == ans)
			{
				ans = vec[j].second;
			}
			else if(vec[j].second == ans)
			{
				ans = vec[j].first;
			}
		}
		pos[ans - 1] = i + 1;
	}
	for(int i = 0; i < w; ++i)
	{
		cout << pos[i] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main() {

	int place[31];
	int w, n;
	cin >> w >> n;
	for(int i = 1; i <= w; i++)
		place[i] = i;
	
	int a, b;
	char c;
	for(int i = 1; i <= n; i++){
		cin >> a >> c >> b;
		
		int temp = place[a];
		place[a] = place[b];
		place[b] = temp;
	}
	
	for(int i = 1; i <= w; i++)
		cout << place[i];
	
	return 0;
}

C++: #include <iostream>
using namespace std;
#include <stdio.h>
#define W 30
#define N 30

int main()
{
	int w, n;
	int a[W];
	int temp;
	int x, y;
	
	cin >> w;
	cin >> n;
	for (int i = 0; i < w; i++) {
		a[i] =i + 1;
	}
	
	for (int i = 0; i < n; i++) {
		scanf("%d, %d", &x, &y);
		temp = a[x - 1];
		a[x - 1] = a[y - 1];
		a[y - 1] =temp;
	}
	
	for (int i = 0; i < w; i++) {
		cout << a[i]  << "\n";
	}
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#define N 30
using namespace std;
int main(){
  int w,n,tmp;
  int lod[N]; int lis[N][3];
  while(cin >> n >> w){
  for(int i = 0;i<n;i++){
    lod[i] = i+1;
  }
 
  for(int i=0;i<w;i++){
    scanf("%d,%d",&lis[i][0],&lis[i][2]);
  }
  for(int i=0;i<w;i++){
    tmp = lod[lis[i][0]-1];
    lod[lis[i][0]-1] = lod[lis[i][2]-1];
    lod[lis[i][2]-1] = tmp;
  }
  for(int i=0;i<n;i++){
    cout << lod[i] << endl;
  }
  }
}