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

int main(){
	int w, n, a, b;
	while(cin>>w){
		vector<pair<int, int> > all;
		cin>>n;
		for(int i=0; i<n; i++){
			scanf("%d,%d", &a, &b);
			all.push_back(pair<int, int>(a, b));
		}
		reverse(all.begin(), all.end());
		for(int i=1; i<=w; i++){
			int ima = i;
			for(int j=0; j<n; j++){
				if(all[j].first == ima) ima = all[j].second;
				else if(all[j].second == ima) ima = all[j].first;
			}
			cout<<ima<<endl;
		}
	}
}

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

int main(){
    int w,n;
    cin>>w>>n;
    int vec[30];
    for(int i=0;i<w;i++)
        vec[i]=i+1;
    for(int i=0;i<n;i++){
        int x,y;char m;
        cin>>x>>m>>y;
        swap(vec[x-1],vec[y-1]);
    }
    for(int i=0;i<w;i++)
        cout<<vec[i]<<endl;
}

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

#define SIZE 30

using namespace std;

int main() {
	int w, n, a, b, temp, node[SIZE];
	cin >> w >> n;

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

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

		temp = node[a - 1];
		node[a - 1] = node[b - 1];
		node[b - 1] = temp;
	}

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

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

#include "stdafx.h"
#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] = stoll(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 <utility>
#include <cstring>
using namespace std;

void swap(int*,int*,int);
int main()
{
  int w,n,i;
  cin>>w>>n;
  int *numline = new int[w];
  for(i=0;i<w;++i){
    numline[i]=i+1;
  }
  int *swapline = new int[2*n];
  for(i=0;i<2*n;i+=2){
    char innum[10];
    cin >>innum;
    int m=0;
    while(innum[m]!=',') ++m;
    if(m==1){
      swapline[i]=innum[0]-48;
      if(strlen(innum)-m-1==1) swapline[i+1]=innum[2]-48;
      else swapline[i+1]=10*(innum[2]-48)+(innum[3]-48);
    }
    else{
      swapline[i]=10*(innum[0]-48)+(innum[1]-48);
      if(strlen(innum)-m-1==1) swapline[i+1]=innum[3]-48;
      else swapline[i+1]=10*(innum[3]-48)+(innum[4]-48);
    }
  }
  swap(numline,swapline,n);
  for(i=0;i<w;++i){
  cout<<numline[i]<<endl;
  }
  delete[] numline;
  delete[] swapline;
  return 0;
}

void swap(int numline[],int swapline[],int n)
{
  for(int i=0;i<2*n;i+=2){
    swap(numline[swapline[i]-1],numline[swapline[i+1]-1]);
  }
}

C++: #include<iostream>

using namespace std;
int data[40];
int main(){

	for(int i=0;i<40;i++)data[i]=i;
	int w;
	int n;
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		char tmp[3];
		cin>>tmp;
		int a=tmp[0]-'0';
		int b=tmp[2]-'0';
		for(int i=1;i<=w;i++){
			if(data[i]==a){
				data[i]=b;
			}
			else if(data[i]==b){
				data[i]=a;
			}
		}
	}
	for(int i=1;i<=w;i++){
		int mi=40;
		int ans;
		for(int j=1;j<=w;j++){
			if(data[j]<mi){
				mi=data[j];
				ans=j;
			}
		}
		cout<<ans<<endl;
		data[ans]=40;
	}
}

C++: #include<stdio.h>

int main(){
int tate,yoko,bou[30][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,%d",&bou[j][1],&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>
using namespace std;
int main(){
	int w, n, a[100] = { 0 },b,d,A=0;
	char c;
	cin >> w, n;
	for (int i = 1; i <= w; i++){
		a[i] = i;
	}
	for (int i = 1; i <= n; i++){
		A = 0;
		cin >> b, c, d;
		A = a[b];
		a[b] = a[c];
		a[c] = A;
	}
	for (int i = 1; i <= w; i++){
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
	int W[31], w, n, a, b;
	int i, j, temp;
	char x;

	cin >> w >> n;
	for(i = 1;i < w+1;i++){
		W[i] = i;
	}
	while(n != 0){
		if(n == 0) break;
		cin >> a >> x >>  b;
		temp = W[a];
		W[a] = W[b];
		W[b] = temp;
 		n--;
	}
	for(i = 1;i < w+1;i++){
		cout << W[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main() {
  int w,n,a1,b1,change;
  int num[30];
  string str;
  cin >> w;
  for(int i=1;i<w+1;i++) {
    num[i] = i;
  }
  cin >> n;
  for(int i=1;i<n+1;i++) {
    cin >> str;
    a1 = strtol(str.substr(0).c_str(),NULL,0);
    b1 = strtol(str.substr(2).c_str(),NULL,0);
    change = num[a1];
    num[a1] = num[b1];
    num[b1] = change;
  }
  for(int i=1;i<w+1;i++) {
    cout << num[i] << endl;
  }
}

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

C++: ///
// File:  0011.cpp
// Author: ymiyamoto
//
// Created on Thu Nov  9 00:53:28 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  uint32_t w, n;
  cin >> w;
  cin >> n;

  vector<uint32_t> lines;
  for (uint32_t i = 1; i <= w; i++) {
    lines.push_back(i);
  }

  for (uint32_t i = 0; i < n; i++) {
    uint32_t a, b;
    char sep;
    cin >> a >> sep >> b;
    swap(lines[a - 1], lines[b - 1]);
  }

  for (auto iter = lines.begin(); iter < lines.end(); iter++) {
    cout << *iter << endl;
  }

  return 0;
}

C++: #include <stdio.h>

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