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

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

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

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

int main(){
int w = 0;
cin >> w ;
int n = 0;
cin >> n;
int i = 1;
int a[w];
for(i = 0,i < w,i++){
a[i] = i + 1;
}
for(i = 1,i <= n,i++){
int aa = 0;int bb = 0;
char split;
cin >> aa >> split >> bb ;
int c = 0;
c = a[aa - 1];
a[aa - 1] = a[bb - 1];
a[bb - 1] = c;
}
for(i = 0,i < w, i++){
cout << a[i] << endl;
}
    return 0;
}

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

int main()
{
	int w,n;

	char c;

	std::cin >> w >> n;

	std::vector<int> a(n);

	std::vector<int> b(n);

	std::vector<int> x(w);

	for(int i=0;i<n;++i)
	{
		std::cin >> a[i] >> c >> b[i];
	}

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

	for(int i=0;i<n;++i)
	{
		int temp = x[a[i]-1];

		x[a[i]-1]=x[b[i]-1];

		x[b[i]-1]=temp;
	}

	for(int i=0;i<w;++i)
	{
		std::cout << x[i] << '\n';
	}
}

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

int main()
{
	int n,w,pos[31];


	cin>>w;
	for(int i=0;i<=w;i++) pos[i]=i;
	cin>>n;
	for(int i=0;i<n;i++){
		int left,right;
		string num,str_left,str_right;
		stringstream ss_left,ss_right;
		
		cin>>num;
		int j=0;
		while(num[j] != ','){
			j++;
		}
		str_left=num.substr(0,j);
		ss_left<<str_left;
		ss_left>>left;
		str_right=num.substr(j+1);
		ss_right<<str_right;
		ss_right>>right;
		
	//	cout<<"("<<left<<","<<right<<")"<<endl;

		int temp;
		temp=pos[left];
		pos[left]=pos[right];
		pos[right]=temp;
	}
	for(int i=1;i<=w;i++) cout<<pos[i]<<endl;
}