Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

C++: #include <iostream>
#include <vector>
#include <string>
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 (unsigned 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>
#include <string>
#include <cstdlib>

using namespace std;

#define KANMA string(",")

int main(void) {
	int w, n;

	cin >> w;
	cin >> n;

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

	cin >> ws;
	for (i = 0; i < n; i++){
		int a, b;
		string str;
		string::size_type pos = 0;

		getline(cin, str);
		
		pos = str.find(KANMA, pos);
		a = atoi(str.substr(0, pos).c_str());
		pos += KANMA.length();
		b = atoi(str.substr(pos).c_str());

		int c = ary[a - 1];
		ary[a - 1] = ary[b - 1];
		ary[b - 1] = c;
	}

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

	return 0;
}

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


int main()
{
	int w, n, num[32];
	string s;
	cin >> w;
	fill(num, num + 32, 0);
	for (int i = 1; i < w + 1; i++){
		num[i] = i;
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		string l, r;
		int commapos;

		//カンマの左
		for (int i = 0;; i++){
			if (s[i] == ','){
				commapos = i;
				break;
			}
			else{
				l += s[i];
			}
		}

		//カンマの右
		for (int i = commapos + 1; i < (signed)s.length(); i++){
			r += s[i];
		}
		int left = atoi(l.c_str());
		int right = atoi(r.c_str());
		int temp = num[left];
		num[left] = num[right];
		num[right] = temp;
	}
	for (int i = 1; i < w + 1; i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int h,v,i,l,r,a[31];
char c;
for (i=0;i<31;i++) a[i]=i;
cin >> h >> v;
for (i=0;i<v;i++) {
	scanf("%d%c%d",&l,&c,&r);
	swap(a[l],a[r]);
}
for (i=1;i<=h;i++) cout << a[i] << endl;
return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int main(){
	int hig,wid,tmp,sta[35],fin[35],ans[35];
	char x;
	cin>>hig>>wid;
	for(int i=0;i<wid;i++){
		cin>>sta[i]>>x>>fin[i];
	}
	for(int i=1;i<=hig;i++){
		ans[i-1]=i;
	}
	for(int i=0;i<wid;i++){
		tmp=ans[sta[i]-1];
		ans[sta[i]-1]=ans[fin[i]-1];
		ans[fin[i]-1]=tmp;
	}
	for(int i=0;i<hig;i++){
		cout<<ans[i]<<endl;
	}
}

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

int main(){
  string sa,sb;
  int w,n,a,b,c;
  int num[n];
  cin>>w>>n;
  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 <algorithm>
using namespace std;

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

  for(int i = 0;i<31;i++) s[i] = i;

  cin >> w;
  cin >> n;

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

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

  return 0;
}

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

using namespace std;

int main(){
	int VLineNum, HLineNum;
	cin >> VLineNum;
	cin >> HLineNum;

	int* Data = new int[VLineNum];//あみだくじNo.配列初期化
	for (int i = 0; i < VLineNum; ++i){
		Data[i] = i + 1;
	}

	int a, b, temp;//データロード&あみだくじ数値反転
	for (int i = 0; i < HLineNum; ++i){
		std::scanf("%d,%d", &a, &b);
		temp = Data[b-1];
		Data[b-1] = Data[a-1];
		Data[a-1] = temp;
	}

	for (int i = 0; i < VLineNum; ++i){//出力
		cout << Data[i] << endl;
	}

	delete [] Data;

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
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);
    cin >> w >> n;
    for(int i=0;i<n;i++){
        scanf("%d,%d",&ins.l,&ins.r);
        lines.push_back(ins);
    }
    for(int i=1;i<=w;i++){
        int a=i;
        for(int j=0;j<n;j++){
            if(lines[j].l==a){
                a=lines[j].r;
            }else if(lines[j].r==a){
                a=lines[j].l;
            }
        }
        ans[a-1]=i;
    }
    for(int i=1;i<=w;i++){
        cout << ans[i-1] << endl;
    }
    delete ans;
}

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

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

void swap(int *a, int *b) {
	int x = *a;
	*a = *b;
	*b = x;
}
int main() {
	int w, n, a, b, amida[31];
	char c;
	cin >> w;
	for (int i = 1;i <= w;i++) { amida[i] = i; }
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a >>c>> b;
		swap(&amida[a], &amida[b]);
	}
	for (int i = 1;i <= w;i++)
		cout << amida[i] << endl;
}

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

using namespace std;

int main(){
    int w, n, a, b;
    vector<pair<int, int>> h_lines;
    cin >> w >> n;
    
    while(scanf("%d,%d",&a,&b)+1){
     h_lines.push_back(pair<int, int>(a,b));   
    }
    
    
    for (int i = 0; i < w; ++i){
        int where = i+1;
        for (auto line:h_lines){
            if (line.first == where){
                where = line.second;
            } else if (line.second == where){
                where = line.first;
            }
        }
        cout << where << endl;
    }
    
 return 0;   
}