Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

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;






}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()

int w,n,ans[32];
pair<int,int> list[32];

int main(){	
	scanf("%d%d",&w,&n);
	rep(i,n){
		int a,b; scanf("%d,%d",&a,&b);
		list[i].first = a;
		list[i].second = b;
	}
	REP(i,1,w+1){
		int cur = i;
		rep(j,n){
			if( list[j].first == cur ){
				cur = list[j].second;
				//printf("i:%d , cur:%d\n",i,cur);
			}else if( list[j].second == cur ){
				cur = list[j].first;
				//printf("i:%d , cur:%d\n",i,cur);
			}
		}
		ans[cur] = i;
	}
	REP(i,1,w+1)printf("%d\n",ans[i]);
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<int(n);++i)

int w,n;
int ans[50];
int a,b;

int main(){
	cin>>w>>n;
	rep(i,w){
		ans[i+1] = i+1;
	}
	rep(i,n){
		char t;
		int tmp;
		cin>>a>>t>>b;
		tmp = ans[a];
		ans[a] = ans[b];
		ans[b] = tmp;
	}
	rep(i,w){
		cout<<ans[i+1]<<endl;
	}
	return 0;
}