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;

int main() {
	int N, M; cin >> N >> M;
	vector<int> v(N);
	for (int i = 0; i < N; ++i) {
		v[i] = i;
	}
	for (int i = 0; i < M; ++i) {
		int a, b; scanf("%d,%d", &a, &b); --a, --b;
		swap(v[a], v[b]);
	}
	for (int i = 0; i < N; ++i) {
		cout << v[i]+1 << endl;
	}
}

C++: #include<iostream>

using namespace std;

int main()
{
	int w;
	int n;

	cin >> w >> n;
	int ws[w+1];

	for(int i = 1; i <= w; ++i)ws[i] = i;

	for(int i = 0; i < n; ++i){
		int a,b;
		int tmp;
		char d;
		cin >> a >> d >>b;
		tmp   = ws[a];
		ws[a] = ws[b];
		ws[b] = tmp;
	}
	
	for(int i = 1; i <= w; ++i)cout << ws[i] << endl;

	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a,b,c,d,i,s,x[100];
	scanf("%d %d",&a,&b);
	for(i=0;i<a;i++){
		x[i]=0;
		x[i]=i+1;
	}
	s=0;
	for(i=0;i<b;i++){
		scanf("%d %d",&c,&d);
		s=x[c-1];
		x[c-1]=x[d-1];
		x[d-1]=s;
	}
	for(i=0;i<a;i++){
		printf("%d\n",x[i]);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <cstdint>

int main()
{
	std::uint16_t w, n;
	std::cin >> w;
	std::cin >> n;

	std::vector<std::uint16_t> vnumbers(w);
	std::iota(vnumbers.begin(), vnumbers.end(), 1);

	for (int i = 0; i < n; ++i) {
		std::uint16_t a, b;
		char comma;
		std::cin >> a >> comma >> b;
		std::swap(vnumbers[a - 1], vnumbers[b - 1]);
	}

	std::copy(vnumbers.begin(), vnumbers.end(),
			std::ostream_iterator<std::uint16_t>(std::cout, "\n"));

	return 0;
}

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

using namespace std;

int main(void) {


	//0011
	int Line[31], w=0, n=0, a, b, tmp;
	cin >> w;
	cin >> n;
	for (int i=0; i < 30; i++) {
		Line[i] = i;
	}
	for (int j = 0; j < n; j++) {
		scanf_s("%d,%d", &a, &b);
		tmp = Line[a];
		Line[a] = Line[b];
		Line[b] = tmp;
	}
	for (int k = 1; k <= w; k++) {
		cout << Line[k] << endl;
	}


	return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	
	vector<int> vec(n + 1);
	for(int i = 1; i <= n; ++i){
		vec[i] = i;
	}
	
	for(int i = 0; i < m; ++i){
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap(vec[a], vec[b]);
	}
	
	for(int i = 1; i <= n; ++i){
		cout << vec[i] << endl;
	}
	
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int main(){
    int n,w;
    cin >> w >> n;
    int a[100];
    rep(i,w) a[i] = i+1;
    rep(i,n){
        int x,y;
        char c;
        cin >> x >> c >> y;
        swap(a[x-1],a[y-1]);
    }
    rep(i,w) cout << a[i] << endl;
}

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

int main(){
    int w, n, a, b;
    int amida[31];
    
    for(int i = 0;i < 31;i++){
        amida[i] = i;
    }
    
    cin >> w >> n;
    
    for(int i = 0;i < n;i++){
        scanf("%d,%d",&a,&b);
        swap(amida[a],amida[b]);
    }
    
    for(int i = 1;i <= w;i++){
        cout << amida[i] << endl;
    }
}

C++: #include<iostream>
#include<vector>
#include <stdio.h>
int main(){
	int w;
	std::cin>>w;
	std::vector<int> a(w);
	for(int i=1;i<=w;i++)a[i]=i;
	int n;
	std::cin>>n;
	while(n>0){
		int b,c;
		scanf("%d,%d",&b,&c);
		//std::cin>>b>>c;
		int d=a[b];
		a[b]=a[c];
		a[c]=d;
		n--;
	}
	for(int i=1;i<=w;i++)std::cout<<a[i]<<std::endl;
	return 0;
}

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

using namespace std;
void lots(int len,int a,int b,int array[]){
    int buffer[5];
    for(int i = 0;i < len; i++){
        if(i == a-1){
            buffer[i] = array[b-1];
        }
        else if(i == b-1){
            buffer[i] = array[a-1];
        }
        else{
            buffer[i] = array[i];
        }
    }
    for(int i = 0; i < len; i++){
        array[i] = buffer[i];
    }

}

int main(){
    int len,duration,a,b;
    cin >> len;
    cin >> duration;
    int array[] = {1,2,3,4,5};
    for(int i = 0; i < duration; i++){
        scanf("%d,%d",&a,&b);
        lots(len,a,b,array);
    }
    for(int i = 0; i < len; i++){
        cout << array[i] << endl;
    }
}

C++: /*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/
void Exchange(int *a,int *b){
	int w;
	w = *a;
	*a = *b;
	*b = w;
}
/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	int *goal;
	int w;
	int n;
	int a,b;
	cin >> w >> n;
	goal = new int [w+1];
	for(int i=1;i<=w;i++){
		goal[i] = i;
		//cout << goal[i] << " ";
	}
	//cout << endl;
	for(int i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		Exchange(&goal[a],&goal[b]);
		//cout << goal[a] << " " << goal[b] << endl;
	}
	for(int i=1;i<=w;i++){
		cout << goal[i] << endl;
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

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

typedef struct{
	int x;
	int y;
}t_swap;

int main(){
	int m, n;
	char c;

	cin >> m;
	cin >> n;
	int* w = new int[ m + 1 ];
	t_swap* swap = new t_swap[ n ];

	for ( int i = 0; i < n; ++i ){
		cin >> swap[ i ].x >> c >> swap[ i ].y;
	}

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

	for ( int i = 0; i < n; ++i ){
		int t = w[ swap[ i ].x ];
		w[ swap[ i ].x ] = w[ swap[ i ].y ];
		w[ swap[ i ].y ] = t;
	}

	for ( int i = 1; i < m + 1; ++i ){
		cout << w[ i ] << endl;
	}


	delete[] swap;
	delete[] w;

	return 0;
}