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<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int main(){
    int w,n;
    int a[50],b[50],ans[50];
    scanf("%d%d",&w,&n);
    REP(i,n)
        scanf("%d,%d",a + i,b + i);

    FOR(i,1,w + 1){
        int now = i;
        REP(j,n){
            if(now == a[j])
                now = b[j];
            else if(now == b[j])
                now = a[j];
        }
        ans[now] = i;
    }
    FOR(i,1,w + 1)
        printf("%d\n",ans[i]);
    return 0;
}

C++: #include <cstdio>

int main()
{
        int w, n;
        int lot[30][30];
        int goal[30];

        scanf("%d", &w);
        scanf("%d", &n);
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < w; j++) {
                        lot[i][j] = -1;
                }
        }
        int a, b;
        for (int i = 0; i < n; i++) {
                scanf("%d,%d", &a, &b);
                lot[i][a - 1] = b - 1;
                lot[i][b - 1] = a - 1;
        }
        for (int i = 0; i < w; i++) {
                int cur = i;
                for (int j = 0; j < n; j++) {
                        if (lot[j][cur] >= 0) {
                                cur = lot[j][cur];
                        }
                }
                goal[cur] = i + 1;
        }
        for (int i = 0; i < w; i++) {
                printf("%d\n", goal[i]);
        }

        return 0;
}

C++: #include<cstdio>
int main(){
    int n,w;
    scanf("%d %d",&n, &w);
    int arr[n+1];
    for(int i=0; i<=n; i++)
        arr[i]=i;
    while(w--){
        char s[3];
        //scanf("%s", s);
        //int a=s[0]-'0', b=s[2]-'0';
        int a,b;
        scanf("%d,%d",&a,&b);
        //cin>>a>>,>>b;
        int memo=arr[a];
        arr[a]=arr[b];
        arr[b]=memo;
    }
    for(int i=1; i<=n; i++)
        printf("%d\n", arr[i]);
    return 0;
}

C++: #include<iostream>

int listen_lineCount();
void listen_path(int &from,int &to);

class Lots
{
private:
	int *start_goal;
	int verLineNum;
public:
	Lots(const int lineCount);
	~Lots();
	
	void draw_line(const int from,const int to);
	void echo_goalNums();
};

//-------------------------main--------------------------------

int main()
{
	int ver_lineCount=listen_lineCount();
	Lots inst_lot=Lots(ver_lineCount);
	
	int hor_lineCount=listen_lineCount();
	
	int from,to;
	for(int roop=0;roop<hor_lineCount;roop++)
	{
		listen_path(from,to);
		inst_lot.draw_line(from,to);
	}
	
	inst_lot.echo_goalNums();
	return 0;
}

//--------------------------------------------------------------

Lots::Lots(const int lineCount)
{
	verLineNum=lineCount;
	start_goal=new int(lineCount+2);
	
	for(int roop=1;roop<=lineCount;roop++)
	{
		start_goal[roop]=roop;
	}
}

Lots::~Lots()
{
	delete [] start_goal;
}

void Lots::draw_line(const int from,const int to)
{
	int swap=start_goal[from];
	start_goal[from]=start_goal[to];
	start_goal[to]=swap;
}

void Lots::echo_goalNums()
{
	using namespace std;
	
	for(int roop=1;roop<=verLineNum;roop++)
	{
		cout<<start_goal[roop]<<endl;
	}
}


int listen_lineCount()
{
	using namespace std;
	
	int lineCount;
	cin>>lineCount;
	
	return lineCount;
}

void listen_path(int &from,int &to)
{
	using namespace std;
	
	char delim;//カンマ区切り
	
	cin>>from>>delim>>to;
}

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) {
		string s;
		cin >> s;
		std::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] = std::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<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int w, n;
vi va;

int main(){
    cin >> w >> n;
    rep(i, w)va.push_back(i + 1);
    rep(i, n){
        int a, b;
        scanf("%d, %d", &a, &b);
        a--; b--;
        swap(va[a], va[b]);
    }
    rep(i, w)cout << va[i] << endl;
}

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

class amida{
private:
	int wnum, w[30], n, a[30], b[30];
public:
	amida(int c, int d, int e[], int f[]);
	void set_w();
	void swap_amida();
	void disp();
};

amida::amida(int c, int d, int e[], int f[]){
	wnum = c;
	n = d;
	for(int i = 0; i < n; i++){
		a[i] = e[i];
		b[i] = f[i];
	}
}

void amida::set_w(){
	for(int i = 0; i < wnum; i++){
		w[i] = i;
	}
}

void amida::swap_amida(){
	for(int i = 0; i < n; i++){
		swap(w[(a[i] - 1)], w[(b[i] - 1)]);
	}
}

void amida::disp(){
	for(int i = 0; i < wnum; i++){
		cout <<(w[i] + 1)<<endl;
	}
}

int main(){
	int c, d, e[30], f[30];
	cin >>c;
	cin >>d;
	for(int i = 0; i < d; i++){
		scanf("%d,%d", &e[i], &f[i]);
	}
	
	amida hoge(c, d, e, f);
	hoge.set_w();
	hoge.swap_amida();
	hoge.disp();
	
	return 0;
}

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';
		int t=data[a];
		data[a]=data[b];
		data[b]=t;
	}
	
	for(int i=1;i<=w;i++)cout<<data[i]<<endl;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>
#include <cmath>

int main(void)
{
  int w, n;

  std::cin >> w >> n;

  std::vector<int> base;
  for (int i = 0; i < w; i++) {
    base.push_back(i + 1);
  }

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

  for (int i = 0; i < w; i++) {
    std::cout << base[i] << std::endl;
  }

  return 0;
}