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++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int w, n;
	cin >> w >> n;
	VI a(w);
	rep(i, w)a[i] = i + 1;
	rep(i, n) {
		int x, y;
		scanf("%d,%d", &x, &y);
		swap(a[x - 1], a[y - 1]);
	}
	rep(i, w) cout << a[i] << endl;
}

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;
		char d;
		cin>>a>>d>>b;
		swap(out[a-1],out[b-1]);
	}
	rep(i,m)cout<<out[i]<<endl;

}

C++: #include<iostream>
#include<stdio.h>

using namespace std;


typedef struct{
	int a,b;
}Line;

void Change(int*n, Line*l){
	if(*n==l->a){
		*n = l->b;
	}else if(*n==l->b){
		*n = l->a;
	}
}

int main(){
	
	int w,n;
	Line *l;
	int *bottom;
	int cur;
	
	
	cin>>w;cin>>n;
	
	l=new Line[n];
	bottom=new int[w];
	
	for(int i=0;i<n;++i){
		scanf("%d,%d",&(l[i].a),&(l[i].b));
	}
	
	for(int i=0;i<w;++i){
		cur = i+1;
		
		for(int j=0;j<n;++j){
			Change(&cur,&(l[j]));
		}
		
		bottom[cur-1] = i+1;
	}
	
	for(int i=0;i<w;++i)
		cout<<bottom[i]<<endl;

	return 0;

}

C++: //
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int w = 0;
    cin >> w;
    
    int n = 0;
    cin >> n;
    
    int c[w];
    for(int i = 0; i < w; i++){
        c[i] = i + 1;
    }
    
    int a, b;
    int buffer;
    for (int i = 0; i < n; i++) {
        scanf("%d,%d",&a, &b);
        //printf("a: %d, b: %d ;; ", a, b);
        //printf("%d, %d -> ", c[a - 1], c[b - 1]);
        buffer = c[a - 1];
        c[a - 1] = c[b - 1];
        c[b - 1] = buffer;
        //printf("%d, %d\n", c[a - 1], c[b - 1]);
    }
    for (int i = 0; i < w; i++) {
        printf("%d\n", c[i]);
    }
    
    
    
    return 0;
}

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

int main() {
  int i, temp;
  int w, n, ai, bi;

  cin >> w;
  cin >> n;

  vector<int> amida;

  // initialize
  for (i = 0; i < w; i++) {
    amida.push_back(i + 1);
  }

  for (i = 0; i < n; i++) {
    scanf("%d,%d", &ai, &bi);

    // swap
    temp = amida.at(ai - 1);
    amida.at(ai - 1) = amida.at(bi - 1);
    amida.at(bi - 1) = temp;
  }

  for (i = 0; i < w; i++) {
    cout << amida.at(i) << endl;
  }

  return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
        int n = 0;
        cin >> n;

        int count = 0;
        cin >> count;

        int i;

        int num[n];

        for(i=0;i<n;i++)
        {
                num[i] = i + 1;
                //cout << num[i] <<endl;
        }

        int a,b;
        int temp;

        for(i = 0;i < count;i++)
        {
                scanf("%d,%d",&a,&b);
                temp = num[a-1];
                num[a-1] = num[b-1];
                num[b-1] = temp;
        } 
        for(i = 0;i < n;i++)
        {
                cout << num[i] << endl;
        } 

}

C++: #include <stdio.h>

struct path {
	int a ;
	int b ;
} p[33] ;

int w ;
int n ;
int ans[35] ;

int main ( )
{
	while ( scanf ( "%d" , &w ) == 1 ) {
		scanf ( "%d" , &n ) ;
		for ( int i = 0 ; i < n ; i++ ) {
			scanf ( "%d,%d" , &p[i].a , &p[i].b ) ;
			p[i].a-- ;
			p[i].b-- ;
		}
		for ( int i = 0 ; i < w ; i++ ) {
			int tmp = i ;
			for ( int j = 0 ; j < n ; j++ ) {
				if ( tmp == p[j].a ) {
					tmp = p[j].b ;
				}
				else if ( tmp == p[j].b ) {
					tmp = p[j].a ;
				}
			}
			ans[tmp] = i ;
		}
		for ( int i = 0 ; i < w ; i++ ) {
			printf ( "%d\n" , ans[i] + 1 ) ;
		}
	}
	return 0 ;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int d[30];
int main() {
	int w, n; scanf("%d%d", &w, &n);
	rep(i, w)d[i] = i + 1;
	rep(i, n) {
		int a, b; scanf("%d,%d", &a, &b); a--; b--;
		swap(d[a], d[b]);
	}
	rep(i, w)printf("%d\n", d[i]);
}

C++: #include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

void swap(int& x, int& y) {
  int tmp = x;
  x = y;
  y = tmp;
}

int main() {
  int w, n;
  int ws[30];
  cin >> w;
  REP(i,w-1) { ws[i] = i+1; }
  cin >> n;
  REP(i,n-1) { 
    char dummy;
    int a, b;
    cin >> a;
    cin >> dummy;
    cin >> b;
    swap(ws[a], ws[b]);
  }
  REP(i,w-1) { cout << ws[i] << endl; }
  return 0;
}

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main(){
	int VLineNum, HLineNum;
	cin >> VLineNum;
	cin >> HLineNum;

	int* Data = new int[VLineNum];//あみだくじNo.配列初期化
	for (int i = 0; i < VLineNum; ++i){
		Data[i] = i + 1;
	}

	int a, b, temp;//データロード&あみだくじ数値反転
	for (int i = 0; i < HLineNum; ++i){
		scanf("%d,%d", &a, &b);
		temp = Data[b-1];
		Data[b-1] = Data[a-1];
		Data[a-1] = temp;
	}

	for (int i = 0; i < VLineNum; ++i){//出力
		cout << Data[i] << endl;
	}

	delete [] Data;

	return 0;
}

C++: #include<stdio.h>

void swap(int*, int*);

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

void swap(int *a, int *b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

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

using namespace std;

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