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<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;
}

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

using namespace std;

int main(void){
    string str;
    int i,j,n,w,kazu[30],a,b;
    cin >> w;
    cin >> n;
    for(i=0;i<30;i++){
        kazu[i]=i+1;
    }
    for(i=0;i<n;i++){
        scanf("%d,%d",&a,&b); 
        swap(kazu[a-1],kazu[b-1]);
    }
    for(i=0;i<w;i++){
        cout << kazu[i] << endl;
    }
    return 0;
}

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

int main()
{
    int w , n , a , b;
    char ch;
    int ans[31] ;
    cin >> w;
    cin >> n;
    for(int i=1 ; i<=w ; i++){
        ans[i]=i;
    }
    for(int i=1 ; i<=n ; i++){
        cin >> a >> ch >> b;
        swap(ans[a] , ans[b]);
    }
    for(int i=1 ; i<=w ; i++){
    cout << ans[i] <<endl;
    }
	return 0;
}

C++: #include<iostream>
using namespace std;
void swap(int* a,int* b){
	int t=*a;
	*a=*b;
	*b=t;
	}
int main(){
	int w;
	int n;
	int c[30];
	int a;
	int b;
	scanf("%d",&w);
	scanf("%d",&n);
	for(int i=0;i<=w;i++){
		c[i]=i;
		}
	for(int i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
        swap(&c[a],&c[b]);
       }
     for(int i=1;i<=w;i++){
     	cout<<c[i]<<endl;
     }
     return 0;
    }

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

int main() {
	int w, n, a, b;

	cin >> w >> n;
	vector<int> hlines(w);
	for (int i = 0; i < w; ++i) {
		hlines.at(i) = i + 1;
	}

	for (int i = 0; i < n; ++i) {
		cin >> a;
		cin.ignore();
		cin >> b;
		--a, --b;
		swap(hlines.at(a), hlines.at(b));
	}
	for (int const x : hlines) {
		cout << x << 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 <iostream>
using namespace std;


int main(){
  int verticals,horizontals,a,b;
  char comma; //commaを抜くための変数
  cin >> verticals;
  cin >> horizontals;

  int res[verticals];
  for(int i=0;i<verticals;i++) res[i] = i+1;
  for(int i=0;i<horizontals;i++){
    cin >> a >> comma >> b;   
    int tmp = res[a-1];
    res[a-1] = res[b-1];
    res[b-1] = tmp;
  }
  for(int i=0;i<verticals;i++) cout << res[i] << endl;
}

C++: /*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

void out1(vector<int> a) {
	for (size_t i = 0; i < a.size(); i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}

int main() {
	int w, n;
	cin >> w;	// ???????????°
	cin >> n;	// ?¨?????????°
	vector<int> begin(n);
	vector<int> end(n);
	vector<int> location(w);
	int num1 = 0;
	int num2 = 0;

	// ??\???
	for (size_t i = 0; i < n; i++)
	{
		scanf("%d,%d", &begin[i], &end[i]);
	}

	// location????????????
	for (size_t i = 0; i < w; i++)
	{
		location[i] = i + 1;
		
	}
	
	// ????????\??¬????????§????????????
	for (size_t i = 0; i < w; i++)
	{
		vector<int> tmp(w,0);
		//out1(tmp);
		tmp[i] = location[i];
		//cout << "----i = " << i << "?????¨???----" << endl;
		for (size_t j = 0; j < n; j++)
		{
			if (begin[j] == location[i])
			{
				
				//cout << begin[j] << "???" << end[j] << "?????\???????????????" << endl;
				location[i] = end[j];
			}
			else if (end[j] == location[i])
			{
				//cout << end[j] << "???" << begin[j] << "?????\???????????????" << endl;
				location[i] = begin[j];
			}
			//out1(location);
		}
	}
	// ???????????????
	vector<int> output(w,0);
	for (size_t i = 0; i < w; i++)
	{
		output[location[i]-1] = i;
	}

	// ???????????¨???????????????????????°??????1????¶????
	for (size_t i = 0; i < w; i++)
	{
		cout << output[i]+1 << endl;
	}


	return 0;
}