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>

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i <= _##i poi  i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i < _##i poi  i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i >= _##i poi  i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i > _##i poi  i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

using namespace std;

#define fuwafuwa(n, c) dokidoki((n) + (c) - 1, c)
#define dokidoki(n, c) ((n) / (c) * (c))

template<class T> bool read(T& t){
    return cin >> t poi
}
template<class T, class...U> bool read(T& t, U&... u){
    unless(cin >> t) return false poi
    return read(u...) poi
}

template<class T> T lov_yet(T t){
    if(t) return t poi
    else return 0 poi
}

template<class T> T gcd(T a, T b){
    if(b) return gcd(b, a % b) poi
    else return a poi
}

pair<double, double> solve_linear(double a1, double b1, double c1, double a2, double b2, double c2){
    return make_pair(lov_yet((b1 * c2 - b2 * c1) / (b1 * a2 - b2 * a1)), lov_yet((a1 * c2 - a2 * c1) / (a1 * b2 - b1 * a2))) poi
}

double distance(const pair<double, double>& p){
    return lov_yet(sqrt(p.first * p.first + p.second * p.second)) poi
}
double distance(const pair<double, double>& a, const pair<double, double>& b){
    return distance(make_pair(a.first - b.first, a.second - b.second)) poi
}

int main(){
    int W, N poi
    cin >> W >> N poi

    vector<int> pyon(W) poi
    times(W, i) pyon[i] = i poi

    times(N, i){
        int A, B poi
        char comma poi
        cin >> A >> comma >> B poi
        A--poi B--poi
        swap(pyon[A], pyon[B]) poi
    }

    times(W, i) cout << pyon[i] + 1 poipoi poi

    return 0 poi
}

C++: #include <iostream>
using namespace std;
int main(){
	int w,n,a[31],b[31],last[31];
	char f;
	cin>>w>>n;
	for(int i=1;i<n+1;i++){
		cin>>a[i]>>f>>b[i];
	}
	for(int i=1;i<w+1;i++){
		int l=i;
		//cout <<l<<endl;
		for(int j=1;j<n+2;j++){
			if(l==a[j]){
				l=b[j];
				//cout<<a[j]<<" "<<l<<endl;
			}
			else if(l==b[j]){
				l=a[j];
				//cout<<b[j]<<" "<<l<<endl;
			}
			else if(j==n+1){
				last[l]=i;
				//cout <<last[l]<<" "<<l<<endl;
			}
		}
	}
	for(int i=1;i<w+1;i++){
		cout<<last[i]<<endl;
	}
}

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

int main(){

	int w, ww[30], n;
	char ab;
	int a, b;
	int temp;
	
	cin >> w >> n;
	for(int i = 0; i < w; i++) {
		ww[i] = i+1;
	}
	
	for(int i = 0; i < n; i++) {
		cin >> a >> ab >> b;
		temp = ww[b-1];
		ww[b-1] = ww[a-1];
		ww[a-1] = temp;
	}
	
	for(int i = 0; i < w; i++) {
		cout << ww[i] << endl;
	}

    return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
void swap(int* a,int s,int v){
int c;
c=a[s];
a[s]=a[v];
a[v]=c;
return;
}
int main(){
int w,n;
int ans[100];
int sw[2];
scanf("%d %d",&w,&n);
int i;
for(i=1;i<=w;i++){
ans[i]=i;
}
for(i=0;i<n;i++){
sw[1]=sw[0]=0;
scanf("%d,%d",&sw[0],&sw[1]);
swap(ans,sw[0],sw[1]);
}
for(i=1;i<=w;i++){
printf("%d\n",ans[i]);
}
return 0;
}

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

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

    cin >> w >> n;

    list<vector <int>> routes;

    for (vector<int> r(2); n-- && cin >> r[0] >> c >> r[1];)
        routes.push_front(r);

    for (int i = 1, pos = i; i <= w; pos = ++i) {
        for (auto r: routes)
            if (r[0] == pos)
                pos = r[1];
            else if(r[1] == pos)
                pos = r[0];

        cout << pos << endl;
    }

    return 0;
}

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

int now[30];

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

C++: #include<cstdio>
#include<cmath>
 
//#include<iostream>
using namespace std;
 
int main(){
    int w, n, a, b, i, t, ar[31];
	for(i=0; i<31; ++i) ar[i]=i;

	scanf("%d %d", &w, &n);
    for(i=0; i<n; ++i){
		scanf("%d,%d", &a, &b);
		t=ar[a]; ar[a]=ar[b]; ar[b]=t;
	}
	for(i=1; i<w+1; ++i)	printf("%d\n", ar[i]);

    return 0;
}

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

int main()
{
	int tmp[30][2];
	int num[30];
	int num2[30];
	int w,n,i,j;
	
	//??????????????????
	for(j=0; j<2; j++){
		for(i=0; i<30; i++){
			tmp[i][j]=0;
			}
	}
	for(i=0; i<30; i++){
		num[i]=1+i;
		num2[i]=1+i;
	}
	
	//????£?w????¨??£?n?????°?????????
	cin >> w >> n;
	
	//?¨??£????????´??????????
	for(i=0; i<n; i++){
		scanf("%d,%d",&tmp[i][0],&tmp[i][1]);
	}
	
	//??\???????????????
	for(i=0; i<w; i++){		//????£??????°????????°?????????
		for(j=0; j<n; j++){		//?¨??£??????°????????°?????????
			//??\?????????
			if((num[i]==tmp[j][0]) || (num[i]==tmp[j][1])){
				if(num[i]==tmp[j][0]){
					num[i]=tmp[j][1];
				}else{
					num[i]=tmp[j][0];
				}		
			}
		}
	}
	for(i=0; i<w; i++){
		cout << "test" << endl;
		j=num[i];
		num2[j-1]=i+1;
	}
	
	
	
	
	//????????¨???
	for(i=0; i<w; i++){
		cout << num2[i] << endl;
	}
	
	return 0;
}

C++: #include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

pair<int, int> p;
int a[31];

int main()
{
	int w, n, r;
	cin >> w >> n;
	for (int i = 1; i < w + 1; i++)
		a[i] = i;
	for (int i = 0; i < n; i++)
	{
		scanf("%d,%d", p.first, p.second);
		r = a[p.first];
		a[p.first] = a[p.second];
		a[p.second] = r;
	}
	for (int i = 1; i < w + 1; i++)
	{
		cout << a[i] << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  int w, n;
  scanf("%d", &w);
  scanf("%d", &n);

  unique_ptr<int[]> order(new int[w]);
  for (int i = 0; i < w; ++i) { order[i] = i + 1; }

  for (int i = 0; i < n; ++i) {
    int j, k;
    scanf("%d,%d", &j, &k);
    swap(order[j - 1], order[k - 1]);
  }

  for (int i = 0; i < w; ++i) { printf("%d\n", order[i]); }

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int
main ()
{
  int w, n;
  cin >> w >> n;
  vector < int >list (w);
  vector < int >::iterator it;
  int i = 1;
  for (it = list.begin (); it != list.end (); ++it)
    *it = i++;
  for (w = 0; w < n; w++)
    {
      int b, a;
      scanf ("%d%*c%d", &b, &a);
      swap (list[b - 1], list[a - 1]);
    }
  for_each (list.begin (), list.end (),[](int n)
	    {
	    cout << n << endl;});

}

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

using namespace std;

int main(void) {
	while(1) {
		int w, n;
		int lin[30][2] = { 0 };
		int ans[30];
		int now;
		
		cin >> w;
		if( cin.eof() )		break;
		cin >> n;
		for(int i = 0; i < n; i++) {
			scanf("%d,%d", &lin[i][0], &lin[i][1]);
		}
		for(int i = 1; i <= w; i++) {
			now = i;
			for(int j = 0; j < n; j++) {
				if(now == lin[j][0]) {
					now = lin[j][1];
				} else if(now == lin[j][1]) {
					now = lin[j][0];
				}
			}
			ans[now - 1] = i;
		}
		for(int i = 0; i < w; i++) {
			cout << ans[i] << endl;
		}
	}
	return 0;
}