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<iostream>

using namespace std;

typedef struct B{
	int a;
	int b;
}Link;

int main()
{
	int StrLen, LinkNum;
	int EndNum[50] = {0};
	Link link[50];
	cin >> StrLen >> LinkNum;
	for (int i = 0; i < LinkNum; i++)
		scanf("%d,%d", &link[i].a, &link[i].b);
	for (int i = 1; i <= StrLen; i++)
	{
		int posi = i;
		for (int j = 0; j < LinkNum; j++)
		{			
			if (link[j].a == posi)
				posi = link[j].b;
			else if (link[j].b == posi)
				posi = link[j].a;				
		}
		EndNum[posi-1] = i;
	}
	for (int i = 0; i < StrLen; i++)
		cout << EndNum[i] << endl;

	return 0;
}

C++: #include<iostream>

using namespace std;
 
int main(){
    int W,N;
    int w[30];
 
    cin >> W >> N;

    for(int i=0;i<W;i++)
    w[i] = i+1;
 
    int a, b, dm;
    for(int i=0;i<N;i++) {
    	
        cin >> a >> b; 
        
        dm = w[a-1];
        w[a-1] = w[b-1];
        w[b-1] = dm;
        
        }
 
        for(int i=0;i<W;i++)
            cout << w[i] << "\n"; 
 
        return 0;
}

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

int main()
{
	int w,n;
	scanf("%d",&w);
	scanf("%d",&n);
	int *lot = new int[w+1];
	for(int i=0;i<=w;i++){
		lot[i] = i;
	}
	for(int i=0;i<n;i++){

		string str1,str2;
		int a,b;
		getline(cin,str1,',');
		getline(cin,str2);
		sscanf(str1.c_str(),"%d",&a);
		sscanf(str2.c_str(),"%d",&b);
		swap(lot[a],lot[b]);
	}

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

C++: include <bits/stdc++.h>
using namespace std;

int main() {
	int w,n;
	scanf("%d %d",&w,&n);
	int a[n];
	int b[n];
	for(int i=0;i<n;i++){
		scanf("%d,%d",&a[i],&b[i]);
	}
	int ans[w+1];
	for(int i=1;i<=w;i++)ans[i]=i;
	int temp;
	for(int i=0;i<n;i++){
		temp=ans[a[i]];
		ans[a[i]]=ans[b[i]];
		ans[b[i]]=temp;
	}
	for(int i=1;i<=w;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

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

int main(){
  int W,n;
  cin>>W;
  int num[W+1];
  for(int i=1;i<=W;i++){
    num[i]=i;
  }
  cin>>n;
  int change1=0,change2=0;
  int alt=0;
  for(int i=0;i<n;i++){
    scanf("%d,%d",&change1,&change2);
    alt=num[change1];
    num[change1]=num[change2];
    num[change2]=alt;
  }
  for(int i=1;i<W+1;i++){
    cout<<num[i]<<endl;
  }
  return 0;
}

C++: /*Filename: aoj0011.cpp
 *Author: Mushiyo
 */

#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
	int w = 0;

    while(cin >> w){
    	int num[w + 1];
    	for(int i = 1; i <= w; ++i){
    		num[i] = i;
    	}

        int n = 0;
        cin >> n;

        while(n > 0){
        	int a = 0, b = 0;
        	scanf("%d, %d", &a, &b);

        	int tmp = num[a];
        	num[a] = num[b];
        	num[b] = tmp;

        	--n;
        }
        
        for(int i = 1; i <= w; ++i){
        	cout << num[i] << endl;
        }
    }

	return 0;
}

C++: #include <iostream>

using namespace std;

int cell[31];

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

    for (int i = 1; i <= 30; i++) {
        cell[i] = i;
    }

    cin >> w >> n;

    while (n--) {
        int a, b;
        scanf("%d,%d", &a, &b);
        swap(cell[a], cell[b]);
    }

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

    return 0;
}

C++: #include <stdio.h>
#define MAX 30

int main(void){
    int w,n, tmp;
    int a,b;
    int lot[MAX+1]; // 1-origin

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

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

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

C++: #include <iostream>
int main(){
int w,n,b[30],a,c,d,i,f,h;
char g;
std::cin>>w>>n;
for(a=1;a<=w;++a){
    b[a]=a;
    }
for(i=0;i<n;++i){
      std::cin>>c>>g>>d;
       f=b[c];
      b[c]=b[d];
     b[d]=f;
}
for(h=1;h<=w;++h){
  std::cout<<b[h]<<std::endl;
  }
return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#define W 30

int lot[W];

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

int main() {
    int w, n;
    int a, b, tmp;
    std::cin >> w;
    std::cin >> n;
    init_lots(w);
    for (int i=0; i<n; i++) {
        scanf("%d,%d", &a, &b);
        tmp = lot[a];
        lot[a] = lot[b];
        lot[b] = tmp;
    }
    for (int i=1; i<=w; i++) std::cout << lot[i] << std::endl;
    return 0;
}

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

void swap(int* a, int* b) {

	int work;

	work = *a;
	*a = *b;
	*b = work;
}

int main() {

	int w, n;
	cin >> w;
	cin >> n;

	int a[30];
	for (int i = 0; i < 30; i++)a[i] = i + 1;
	int x, y;
	char c;
	for (int i = 0; i < n; i++) {
		cin >> x >> c >> y;

		swap(&a[x - 1], &a[y - 1]);
	}

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

	//system("pause");
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<algorithm>
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 < (signed) 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;
}