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++: w=gets.to_i
n=gets.to_i
a=[*0..w]
n.times{b,c=gets.chomp.split(',').map(&:to_i);a[b],a[c]=a[c],a[b]}
puts a[1..w]

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

int main(){
  string sa,sb;
  int w,n,a,b,c;
  cin>>w>>n;
  int num[w];
  for(int i=0;i<w;i++)
    num[i] = i+1;
  for(;n>0;n--){
    getline(cin,sa,',');
    getline(cin,sb,'\n');
    a = atoi(sa.c_str())-1;
    b = atoi(sb.c_str())-1;
    c = num[a];
    num[a] = num[b];
    num[b] = c;
  }
  for(int i=0;i<w;i++)
    cout << num[i] << endl;
  return 0;
}

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

#define swap(a,b) int c=a;a=b;b=c;

using namespace std;

typedef struct{
    int l;
    int r;
}tint;
int main(){
    
    vector<tint> lines;
    tint ins;
    int w,n;
    int *ans = new int(w+1);
    cin >> w >> n;
    for(int i=0;i<n;i++){
        scanf("%d,%d",&ins.l,&ins.r);
        lines.push_back(ins);
    }
    for(int i=0;i<=w;i++){
        ans[i]=i;
    }
    for(int i=0;i<n;i++){
        swap(ans[lines[i].l],ans[lines[i].r]);
    }

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

C++: #include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)

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

  int lines[w+1];
  REP(i,w+1)
    lines[i] = i;

  REP(i,n){
    int from, to;
    char del;
    cin >> from >> del >> to;
    swap(lines[from], lines[to]);
  }

  for(int i=1; i<w+1; i++)
    cout << lines[i] << endl;

  return 0;
}

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

using namespace std;

int main(){

  int w, n, a, b;

  cin >> w >> n;

  int lot[w];

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

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

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

}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int w, n, a[100], b[100],sw,ap;
	char ch;
	cin >> w >> n;
	for (int i = 1; i <= w; i++) {
		a[i] = i;
	}
	for (int i = 1; i <= n; i++) {
		cin >> sw >> ch >> ap;
		swap(a[sw], a[ap]);
	}
	for (int i = 1; i <= w; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int w, n;
	int l[30];
	int tmp;
	int a, b;
	char c;
	cin >> w >> n;
	for (int i = 0; i < w; i++){
		l[i] = i + 1;
	}
	for (int i = 0; i < n; i++){
		cin >> a >> c >> b;
		a -= 1;
		b -= 1;
		tmp = l[a];
		l[a] = l[b];
		l[b] = tmp;
	}
	for (int i = 0; i < w; i++){
		cout << l[i] << endl;
	}
	cin >> c;
}

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

class Amidakuji{

public:
	int W;
	vector<int> array;//????´?1???????????????
	Amidakuji(int w);
	void Swap(int x,int y);
	void call();
};

//????????????????????????????????????
Amidakuji::Amidakuji(int w){

	for (int i = 0; i < w; i++){
		array.push_back(i+1);//[0,1,2,3,4]={1,2,3,4,5}
	}
	
	W = w;

}

void Amidakuji::Swap(int x,int y){

	//???????????£????????????array[]???????????????
	//int?????§???????????£????????§char???int?????????????????????-48;
	
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	

}

void Amidakuji::call(){

	for (int i = 0; i<W; i++){
		cout << array[i] << endl;
	}

}

int main(){


	int w, n,loc,a,b;
	string text,str_a,str_b,str_v;

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);

			//????????¶?????§??????10,2??????????????¨??????{1,0,,,2}??????????????¢????????£?????????????????§??????????????????????????????????????????

			//?????????????????????????????????????????????????????§?????????????????£?????????????????\????????????????????£???
			loc=text.find(",", 0);
			str_a = text[0];
			for (int j = 1; j < loc; j++){
				str_v = text[j];
				str_a = str_a + str_v;

			}
			str_b = text[loc + 1];
			for (int j = loc + 2; j < text.length(); j++){
				str_v = text[j];
				str_b = str_b + str_v;
			}

			
			a = stoi(str_a);
			b = stoi(str_b);


			if (a != 0 && b != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(a, b);
				a = b = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}

	



	return 0;
}

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

const int max_w = 30;
int w[max_w];

void init(int n){
	for(int i=0;i<n;i++){
		w[i] = i+1;
	}
}
void swap(int a,int b)
{
	int tmp = w[a];
	w[a] = w[b];
	w[b] = tmp;
}
void show(int n)
{
	for(int i=0;i<n;i++){
		cout << w[i] << endl;
	}
}

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

	while(cin >> w && cin >> n){
		init(w);
		for(int i=0;i<n;i++){
			cin >> a  >> c >> b;
			swap(a-1,b-1);
		}
		show(w);
	}
	return 0;
}

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

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

C++: #include<stdio.h>

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

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

typedef pair<int,int> P;

int w,n;
P yoko;	//データは高さ昇順
int pos[32];	//縦棒iからスタートしたとき、今pos[i]番目の縦棒にいる。

int seach(int *p,int num,int size){
	for(int i = 0;i < size;i++){
		if(p[i] == num)
			return i;
	}
	return -1;
}
int main(){
	int i;
	cin >> w >> n;
	for(i = 1;i <= w;i++){
		pos[i] = i;
	}
	for(i = 0;i < n;i++){
		int t1,t2;
		scanf("%d,%d",&yoko.first,&yoko.second);
		t1 = seach(pos,yoko.first,w+1);t2 = seach(pos,yoko.second,w+1);
		//cout << pos[t1] << pos[t2] << endl;
		pos[t1] = yoko.second;
		pos[t2] = yoko.first;
		//cout << pos[t1] << pos[t2] << endl;
	}
	int sita[32];
	for(i = 1;i <= w;i++){
		sita[pos[i]] = i;
	}
	for(i = 1;i <= w;i++)
		cout << sita[i] << endl;
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int i,w,n,a,b,temp;
	int *amida;
	char comma;
	cin>>w>>n;
	amida=new int[w];
	for(i=0;i<w;i++){
		amida[i]=i+1;
	}
	while(n--){
		cin>>a>>comma>>b;
		temp=amida[a-1];
		amida[a-1]=amida[b-1];
		amida[b-1]=temp;
	}
	for(i=0;i<w;i++){
		cout<<amida[i]<<endl;
	}
	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';
		for(int j=1;j<=w;j++){
			if(j==b){
				int tmp=data[a];
				data[a]=data[b];
				data[b]=tmp;
			}
		}
	}
	
	for(int i=1;i<=w;i++)cout<<data[i]<<endl;
}