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<vector>
#include<string>
#include<sstream>
using namespace  std;
int toInt(string s)
{
	int ret;
	stringstream ss;
	ss << s;
	ss >> ret;
	return ret;
}
int main()
{
	int w, n;
	vector<pair<int, int> > v;
	cin >> w >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		int index = s.find(',',0);
		int a = toInt(s.substr(0, index));
		int b = toInt(s.substr(index + 1));
		v.push_back(make_pair(a, b));
	}
	int numbers[40];
	for (int i = 0; i < w; i++)numbers[i] = i + 1;
	for (int i = 0; i < v.size(); i++)
	{
		int tmp = numbers[v[i].first - 1];
		numbers[v[i].first - 1] = numbers[v[i].second - 1];
		numbers[v[i].second - 1] = tmp;
	}
	for (int i = 0; i < w; i++)cout << numbers[i] << endl;
	return 0;
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int w, n, a, b;
    char c;
    cin >> w >> n;

    vector<int> kuji(w);
    REP(i, w) kuji[i] = i + 1;

    REP(i, n)
    {
        cin >> a >> c >> b;
        swap(kuji[a-1], kuji[b-1]);
    }

    REP(i, w) cout << kuji[i] << endl;
    
    return 0;
}

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

int main()
{
	int n,w,pos[31];


	cin>>w;
	for(int i=0;i<=w;i++) pos[i]=i;
	cin>>n;
	for(int i=0;i<n;i++){
		int left,right;
		string num,str_left,str_right;
		stringstream ss_left,ss_right;
		
		cin>>num;
		int j=0;
		while(num[j] != ','){
			j++;
		}
		str_left=num.substr(0,j);
		ss_left<<str_left;
		ss_left>>left;
		str_right=num.substr(j+1);
		ss_right<<str_right;
		ss_right>>right;
		
		cout<<"("<<left<<","<<right<<")"<<endl;

		int temp;
		temp=pos[left];
		pos[left]=pos[right];
		pos[right]=temp;
	}
	for(int i=1;i<=w;i++) cout<<pos[i]<<endl;
}

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 <iostream>
#include <algorithm>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

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

    int w, n;
    cin >> w >> n;
    int a,b;
    char delim;
    for (int i=0; i<n; ++i) {
        cin >> a >> delim >> b;
        swap(s[a],s[b]);
    }

    for (int i=1; i<=n; ++i) {
        cout << s[i] << "\n";
    }

    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	cin>>m>>n;
	vector<int>out(m);
	rep(i,m)out[m]=i+1;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		swap(out[a-1],out[b-1]);
	}
	rep(i,m)cout<<out[i]<<endl;

}

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

int A[40],B[40],ary[40];
int main(){
	int W,N;
	cin>>W>>N;
	char hog[9];
	for(int i=1;i<=N;i++){
		cin>>hog;
		if(strlen(hog)==3){
			A[i]=hog[0]-'0';
			B[i]=hog[2]-'0';
		}
		else if(strlen(hog)==5){
			A[i]=(hog[0]-'0')*10+(hog[1]-'0');
			B[i]=(hog[3]-'0')*10+(hog[4]-'0');
		}
		else if(hog[1]=','){
			A[i]=(hog[0]-'0');
			B[i]=(hog[2]-'0')*10+(hog[3]-'0');
		}
		else{
			A[i]=(hog[0]-'0')*10+(hog[1]-'0');
			B[i]=hog[3]-'0';
		}
	}
	for(int i=1;i<=W;i++){
		ary[i]=i;
	}
	for(int i=1;i<=N;i++){
		swap(ary[A[i]],ary[B[i]]);
	}
	for(int i=1;i<=W;i++){
		cout<<ary[i]<<endl;
	}
	return 0;
}

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

int main()
{
	int w, n = 1;
	cin >> w;
	vector<int> vec(w);
	for (auto& x : vec) x = n++;
	cin >> n;
	for (int i = 0; i < n; i++){
		int a, b;
		char c;
		cin >> a >> c >> b;
		int tmp = vec[a - 1];
		vec[a - 1] = vec[b - 1];
		vec[b - 1] = tmp;
	}
	for (auto x : vec) cout << x << "\n";
	cout.flush();
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int main(){
int w;
cin >> w;
char a;
int n;
cin >> n;
int b[n];
int d[n];
int c;
c=0;
while(c<n){
cin >> b[c]>>a>>d[c];
c=c+1;}
int e[w];
c=0;
while(c<w){
e[c]=c;
c=c+1;}
int f;
int g;
c=0;
while(c<n){
f=e[b[c]-1];
g=e[d[c]-1];
e[d[c]-1]=f;
e[b[c]-1]=g;
c=c+1;}
c=0;
while(c<w){
cout << e[c]+1 <<endl;
c=c+1;}
 
 
}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
#include <sstream>

using namespace std;
typedef pair<int,int> P;
vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

int main(){
  int w,n;
  cin>>w;
  cin>>n;
  int ami[40];
  P bou[40];
  for(int i=0;i<n;i++){
    int x=0,y=0;
    scanf("%d,%d",&x,&y);
    bou[i]=P(x,y);
  }
  for (int i=0;i<w;i++){
    int start=i+1;
    for(int j=0;j<n;j++){
      if(bou[j].first==start){start=bou[j].second;}
      else if(bou[j].second==start){start=bou[j].first;}
    }
    ami[start]=i+1;
  }
  for(int i=1;i<=w-1;i++)cout<<ami[i]<<" ";
  cout<<ami[w]<<endl;






}