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>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

vector<int> makeRangeArray(int n)
{
        static vector<int> vec;
        for(int i = 1; i <= n; i++){
                vec.push_back(i);
        }

        return vec;
}

void exchangeInArray(vector<int>& vec, int a, int b)
{
        if(a <= 0 || b <= 0)
                throw "エラー発生";

        a--;
        b--;

        swap(vec[a],vec[b]);
}

int reader(string str, int& a, int& b)
{
        int i;

        a = 0;
        b = 0;
        for(i=0; str[i] != ','; i++)
        {
                a *= 10;
                a += str[i] - '0';
        }

        for(i++; str[i];i++){
                b *=10;
                b += str[i] - '0';
        }
}

int main()
{
        try{
                int w;
                int n;
                cin >> n;
                cin >> w;
                vector<int> vec = makeRangeArray(n);
                for(int i=0;i<w;i++){
                        int a,b;
                        string str;
                        cin >> str;
                        reader(str, a, b);
                        exchangeInArray(vec, a, b);
                }

                for(auto x:vec){
                        cout << x << endl;
                }
        }
        catch (char *str){
                cout << str << endl;
        }
}

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

int main(){
  int tate,yoko,n,m,a,b,c[31];
  cin>>tate;
  for(int i=1;i<=tate;i++)
    c[i]=i;
  cin>>yoko;
  for(int i=0;i<yoko;i++){
    cin>>a>>b;
    swap(c[a],c[b]);
  }
  for(int i=1;i<=tate;i++)
    cout<<c[i]<<endl;
  return 0;
}

C++: #include <stdio.h>

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

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

using namespace std;

int W,N;

int main(){

	cin>>W>>N;
	array<pair<int,int>,30> p;
	char c;
	for(int i=0;i<N;i++){
		cin>>p[i].first>>c>>p[i].second;
		p[i].first--;
		p[i].second--;
	}
	int cc[30]={0};
	for(int j=0;j<W;j++){
		int co=j;
		for(int i=0;i<N;i++){
			
			if(p[i].first==co){
				co=p[i].second;
			}
			else if(p[i].second==co){
				co=p[i].first;
			}
		}
		cc[co]=j;
		//cout<<co<<endl;
	}
	for(int i=0;i<W;i++){
		cout<<cc[i]+1<<endl;
	}

	return 0;
}

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

int main()
{
	ifstream ifs("Text.txt");
	int w,wl[30],n,a,b,c;
	char ch;
	for(int i=0;i<30;i++){
		wl[i]=i;
	}
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		cin>>ch;
		cin>>b;
		c=wl[a];
		wl[a]=wl[b];
		wl[b]=c;
	}
	for(int i=0;i<w;i++){
		cout<<wl[i+1]<<endl;
	}
}

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

int main(){
    int w,n;
    
    int line[35]={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,31,32,33,34,35};
    cin>>w>>n;
    for(int i=0; i<n; i++){
        int a,b;
       (cin>>a).ignore()>>b;
        swap(line[a],line[b]);
    }
    for(int i=0; i<w;i++){
        cout<<line[i]<<endl;
    }
        return 0;
}

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

int n;
int m;
int ans[1000];

int main() {
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    ans[i] = i;
  }

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

  for (int i=1; i<=n; i++) {
    printf("%d\n", ans[i]);
  }
}

C++: #include<stdio.h>
int main()
{
  int sen[31],y,i,k,hon,m,h;
  scanf("%d",&hon);
  for(i=1;i<=hon;i++)sen[i]=i;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d,%d",&m,&h);
    y=sen[m];
    sen[m]=sen[h];
    sen[h]=y;
  }
  for(i=1;i<=hon;i++)printf("%d\n",sen[i]);
  return 0;
}

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

using namespace std;

void swap(int&, int&);

int main(){
  int w, n, a, b;
  char c;
  vector<int> x;

  cin >> w;
  cin >> n;

  for(int i=0; i<=w; ++i)
    x.push_back(i);

  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;

  return 0;
}

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

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>
#include <typeinfo>
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) {
		int swap[2]; char kanma;
		cin >> swap[0] >> kanma >> swap[1];
		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<iostream>
#include<stdio.h>
#include<stdlib.h>

using namespace std;

int main(void) {


	//0011
	int Line[31], w=0, n=0, a, b, tmp;
	cin >> w;
	cin >> n;
	for (int i=0; i < 30; i++) {
		Line[i] = i;
	}
	for (int j = 0; j < n; j++) {
		scanf("%d,%d", &a, &b);
		tmp = Line[a];
		Line[a] = Line[b];
		Line[b] = tmp;
	}
	for (int k = 1; k <= w; k++) {
		cout << Line[k] << endl;
	}


	return 0;
}

C++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#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 ld long double
int main()
{
	int w, n;

	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	int a[32];
	for (int i = 0; i < 32; i++)
	{
		a[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		string d[2];
		for (int i = 0; i < s.length; i++) {
			if (s[i] == ',') { d[0] = s.substr(0, i); d[i] = s.substr(i + 1); break; }
		}
		int swap[2];
		for (int i = 0; i < 2; i++) {
			swap[i] = stoi(d[i]);
		}
		int before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int w,n;
  cin >> w >> n;
  int d[w+1];
  for(int i = 1 ; i <= w ; i++ )d[i] = i;
  for(int i = 1 ; i <= n ; i++ ){
    int a,b;
    char c;
    cin >> a >> c >> b;
    swap(d[a],d[b]);
  }
  for(int i = 1 ; i <= w ; i++ )cout << d[i] << endl;
}