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 <stdio.h>
using namespace std;
int main(){
	int n , w , i , j , a , b;
	int number[40] ;
	cin >> w ;
	cin >> n;
	for( i=1 ; i<=n ; i++ ){
		scanf( "%d,%d" , &a , &b );
		int x = number[a];
		number[a] = number[b];
		number[b] = x ;
	}
	for( i=1 ; i<=w ; i++ )
		cout << number[i] << endl;
}

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;
	x -= 48;
	y -= 48;
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	for (int i = 0;i<W; i++){
		cout << array[i];
	}cout << endl;


}

void Amidakuji::call(){

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

}

int main(){

	int w, n;
	string text;

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			cout << i<<endl;
			getline(cin, text);
			if (text[0] != 0 && text[2] != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(text[0], text[2]);
				text[0] = text[2] = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}


	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#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;
  }
  }
}

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

int main(void){
  int s[30];
  int w,n;

  for(int i = 0;i<30;i++) s[i] = i;

  cin >> w;
  cin >> n;

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

  for(int i = 1;i<=w;i++) cout << s[i] << endl;

  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main() {
	int num,a=0,b=0,draw;
	cin >> num;
	int *line = new int[num];
	for (int w = 0; w < num; w++) {
		line[w] = w + 1;
	}
		cin >> draw;
		for (int w = 0; w < draw; w++) {
			scanf("%d,%d", &a, &b);
			swap(line[a-1], line[b-1]);
		}
		for (int w = 0; w < num; w++) {
			cout<<line[w]<<endl;
		}
	return 0;
}

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

using namespace std;

int main(void){
  char c;
  int w, n, a, b;
  vector<int> v;
  vector<pair<int, int> > p;

  cin >> w;
  cin >> n;
  for(int i=1; i<=w; i++){
    v.push_back(i);
  }

  for(int i=0; i<n; i++){
    cin >> a >> c >> b;
    p.push_back(make_pair(a, b));
  }

  for(int i=0; i<n; i++){
    swap(v[p[i].first-1], v[p[i].second-1]);
  }

  for(int i=0; i<w; i++){
    cout << v[i] << endl;
  }
  return 0;
}

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

using namespace std;

int main(void) {
	int w, n, a, b;
	int i;
	int out[31], tmp;

	cin >> w;
	cin >> n;

	for(i=0;i<w;i++) {
		out[i] = i+1;
	}

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

	for(i=0;i<w;i++) {
		cout << out[i] << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  string str;
  char ch;
  int w, n, a, b;
  cin >> w >> n;
  vector<int> num(w, 0);
  for(int i = 0; i < w; i++) num.at(i) = i + 1;
  
  for(int i = 0; i < n; i++){
    cin >> a >> ch >> b;
    swap( num.at(a - 1), num.at(b - 1));
  }
  
  for(int i = 0; i < w; i++) cout << num.at(i) << endl;
}

C++: #include<stdio.h>

int main(){
	int tate,yoko,bou[40][2],j,x,kekka[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30},i=0;
	scanf("%d %d",&tate,&yoko);
	for(j=0;j<yoko;j++){
		scanf("%d",&bou[j][1]);
		printf(",");
		scanf("%d",&bou[j][2]);
	}
	for(i=1;i<tate+1;i++){
		x=i;
		for(j=0;j<yoko;j++){
			if(bou[j][1]==x){
				x=bou[j][2];
			}
			else if(bou[j][2]==x){
				x=bou[j][1];
			}
		}
		kekka[x-1]=i;
	}
	for(j=0;j<tate;j++){
		printf("%d\n",kekka[j]);
	}
}

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main(){

	int n , w;
	int a , b , ary[100];

	cin >> w >> n;

	for(int i = 1; i <= w; i++){
		ary[i] = i;
	}

	for(int i = 0; i < n; i++){
		scanf("%d,%d" ,&a ,&b);

		int tmp = ary[a];
		ary[a] = ary[b];
		ary[b] = tmp;
	}

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

	return 0;
}

C++: //0011
#include <bits/stdc++.h>
using namespace std;

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

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

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

C++: #include <bits/stdc++.h>

using namespace std;

int main() {
  int w, n;
  cin >> w >> n;
  vector<int> k(w);
  for (int i = 0; i < w; ++i) k[i] = i;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a;
    cin.ignore();
    cin >> b;
    swap(k[a - 1], k[b - 1]);
  }
  for (int i : k) cout << i + 1 << endl;
}

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