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++: /*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;
}

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

int w,n;
int a,b;
int l[30];

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

        return 0;

}

C++: #include<iostream>

using namespace std;
 
int main() {
	
    int L[30];
    for(int i=0;i<30;i++)
	L[i]= i + 1;
	
    int a, b;
    cin >> a >> b;
    for(int i=0;i<b;i++){
    	
        int c,d;
        cin >> c >> d;
        
        int s = L[c-1];
        L[c-1] = L[d-1];
        L[d-1] = s;
        
    }
    for(int i=0;i<a;i++)
	cout << L[i] << "\n";
	
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int w,n,a,b,ans[30];
cin >> w >> n;
for(int i=0;i<w;i++)ans[i]=i+1;
for(int i=0;i<n;i++){
cin >> a >> b;
swap(ans[a-1],ans[b-1]);
}
for(int i=0;i<w;i++)printf("%d\n",ans[i]);
return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<memory>
#include<array>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
  int w, n;
  int a, b;
  char c;
  
  array<int, 30> kuji;
  
  cin >> w;
  cin >> n;

  for ( int i = 0; i < kuji.size(); i++ )
    kuji[i] = i+1;
  
  for ( int i = 0; i < n; i++ )
    {
      cin >> a >> c >> b;
      swap( kuji[a-1], kuji[b-1] );
    }

  for ( int i = 0; i < w; i++ )
    cout << kuji[i] << endl;

  return 0;
}

C++: #include <cstdio>
#define LOOP(index,times) for(int index=0;index<times;index++)
using namespace std;

int main(){

int w,n,a,b,temp;
int* num;

scanf("%d\n%d",&w,&n);

num=new int[w];

LOOP(i,w)
	num[i]=i+1;

LOOP(i,n){
	scanf("%d,%d",&a,&b);
	temp=num[a-1];
	num[a-1]=num[b-1];
	num[b-1]=temp;
}

LOOP(i,w)
	printf("%d\n",num[i]);

delete [] num;
return 0;		
}

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

using namespace std;

int main() {
	int w, n;
	int a, b;
	cin >> w >> n;
	int *W = new int[w];
	for (int i = 0; i < w; i++)
		W[i] = i + 1;

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

	for (int i = 0; i < w; i++)
		cout << W[i] << endl;

	delete[] W;
	return 0;
}