Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

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

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

C++: #include<stdio.h>

int main(){

int x[32][2]={};
int w,n;

scanf("%d",&w);
scanf("%d",&n);
for(int i=0;i<=w;i++)
x[i][0]=i;

for(int i=0;i<n;i++)
{
int a1,a2;
scanf("%d,%d",&a1,&a2);
int t=x[a1][0];x[a1][0]=x[a2][0];x[a2][0]=t;
}

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

return 0;
}

C++: #include <stdio.h>

void swap(int *a, int *b){
int c=*a;
*a=*b;
*b=c;
return;
}

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

C++: #include <iostream>

using namespace std;

int main(){
    int tate[30], w, n, a, b;
    char comma;
    for(int i=0;i<30;i++) tate[i]=i+1;
    
    cin >> w;
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> a >> comma >> b;
        swap(tate[a-1],tate[b-1]);
    }
    
    for(int i=0;i<w;i++){
        cout << tate[i] << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

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

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

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

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

C++: #include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int w,n;
    cin>>w>>n;
    int c[40];
    for(int i=1;i<=w;i++){
        c[i]=i;
    }
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d,%d",&a,&b);
        swap(c[a],c[b]);
        
    }
    for(int i=1;i<=w;i++){
        cout<<c[i]<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int lot[31];
  for(int i=1;i<=30;i++){
    lot[i]=i;
  }
  int w,n;
  cin>>w>>n;
  for(int i=0;i<n;i++){
    int a,b;
    (cin>>a).ignore()>>b;
    swap(lot[a],lot[b]);
  }
  for(int i=1;i<=w;i++){
    cout<<lot[i]<<endl;
  }
  return 0;
}

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;
	}

}

//???????????§?????????????????°?????????????????????????????§???????????????????????°??????????????¢??°
void Func(string str,char a){



};



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 <bits/stdc++.h>
using namespace std;

int main() {
	ios :: sync_with_stdio(false);
	int p[31]; iota(p, p + 31, 0);
	int w, n; cin >> w >> n;
	while(n --) {
		int i, j; char c;
		cin >> i >> c >> j;
		swap(p[i], p[j]);
	}
	for(int i = 1; i <= w; i ++)
		cout << p[i] << '\n';
	return 0;
}

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



int main()
{

    int JumlahGarisVertikal;
    int JumlahGarisHorizontal;
    int DaftarAngka[30];
    int TukarNilai[30][2];

    cin >> JumlahGarisVertikal;
    cin >> JumlahGarisHorizontal;

    for(int x = 0 ; x < JumlahGarisVertikal; x++)
    {
        DaftarAngka[x] = x+1;
    }

    for(int y = 0; y < JumlahGarisHorizontal; y++)
    {
        scanf("%d,%d",&TukarNilai[y][0],&TukarNilai[y][1]);

        int temp = DaftarAngka[TukarNilai[y][0] - 1];
        DaftarAngka[TukarNilai[y][0] - 1] = DaftarAngka[TukarNilai[y][1] - 1];
        DaftarAngka[TukarNilai[y][1] - 1] = temp;
    }

    for(int z = 0; z < JumlahGarisVertikal; z++)
    {
        cout << DaftarAngka[z] << endl;
    }

}

C++: #include <iostream>

using namespace std;

int main()
{
    int w, n;
    char comma;
    int a, b;
    int ans[32];
    
    cin >> w >> n;
    for (int i = 1; i <= w; i++)
        ans[i] = i;

    for (int i = 0; i < n; i++) {
        cin >> a >> comma >> b;
        int tmp = ans[a];
        ans[a] = ans[b];
        ans[b] = tmp;
    }

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

    return 0;
}

C++: #include <stdio.h>

void swap(int *a, int *b){
int c=*a;
*a=*b;
*b=c;
return;
}

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