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

int main() {
	int w, n, a, b; cin >> w >> n; int arr[w]; char cha;
	for (int i = 0; i < w; i++) arr[i] = i + 1;
	for (int i = 0; i < n; i++) {
		cin >> a >> cha >> b; swap(arr[a - 1], arr[b - 1]);
	}
	for (int i = 0; i < w; i++) cout << arr[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<iostream>
#include <cstdio>

using namespace std;

int main() {

	int no[30] = {0};
	int N,m,a,b;
	char connma;

	cin >> N;
	cin >> m;

	for (int i = 0; i < N; i++) {
		no[i] = i+1;
	}
	
	for (int i = 0; i < m; i++) {
		cin >> a >> connma >> b;
		swap(no[a - 1], no[b - 1]);
	}

	for (int i = 0; i < N; i++) {
		cout << no[i] << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)
 
typedef vector<int> vi;
 
int main()
{
    int w, n;
    scanf("%d%d", &w, &n);
 
    vi line(w);
    rep(i, w) line[i] = i+1;
    rep(i, n){
        int a, b;
        scanf("%d,%d", &a, &b);
        swap(line[a-1], line[b-1]);
    }
 
    rep(i, w) printf("%d\n", line[i]);
 
    return 0;
}

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

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

C++: #include<stdio.h>

int main(){

int x[32][2]={};
int w,n;

scanf("%d",&w);
scanf("%d",&n);
for(int i=0;i<=w;i++)
x[i][0]=i;

for(int i=0;i<n;i++)
{
int a1,a2;
scanf("%d,%d",&a1,&a2);
int t=x[a1][0];x[a1][0]=x[a2][0];x[a2][0]=t;
}

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

return 0;
}

C++: #include <stdio.h>

void swap(int *a, int *b){
int c=*a;
*a=*b;
*b=c;
return;
}

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

C++: #include <iostream>

using namespace std;

int main(){
    int tate[30], w, n, a, b;
    char comma;
    for(int i=0;i<30;i++) tate[i]=i+1;
    
    cin >> w;
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> a >> comma >> b;
        swap(tate[a-1],tate[b-1]);
    }
    
    for(int i=0;i<w;i++){
        cout << tate[i] << endl;
    }
    return 0;
}

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

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

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

int main(){
	int x[30],w;
	cin >> w;
	for(int i = 1; i <= w; i++){
		x[i] = i;
	}
	
	int n, a, b;
	char c;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a >> c >> b;
		swap(x[a],x[b]);
	}
	
	for(int i = 1; i <= w; i++){
		cout << x[i] << endl;
	}
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,m,lots[50];
  cin >>n>>m;
  for(int i=0; i<50; i++){lots[i] = i+1;}
  while(m--){
    int a,b,c;
    scanf("%d,%d",&a,&b);
    c = lots[a-1];
    lots[a-1] = lots[b-1];
    lots[b-1] = c;
  }
  for(int i=0; i<n; i++){cout <<lots[i]<<endl;}
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int w,n;
    cin>>w>>n;
    int c[40];
    for(int i=1;i<=w;i++){
        c[i]=i;
    }
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d,%d",&a,&b);
        swap(c[a],c[b]);
        
    }
    for(int i=1;i<=w;i++){
        cout<<c[i]<<endl;
    }
    return 0;
}

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

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

}

//???????????§?????????????????°?????????????????????????????§???????????????????????°??????????????¢??°
void Func(string str,char a){



};



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 <bits/stdc++.h>
using namespace std;

int main() {
	ios :: sync_with_stdio(false);
	int p[31]; iota(p, p + 31, 0);
	int w, n; cin >> w >> n;
	while(n --) {
		int i, j; char c;
		cin >> i >> c >> j;
		swap(p[i], p[j]);
	}
	for(int i = 1; i <= w; i ++)
		cout << p[i] << '\n';
	return 0;
}