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

C++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(ll a=0;a<t;a++)
int main()
{
	ll w, n;

	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	ll a[32];
	roop(i, 32) {
		a[i] = i + 1;
	}
	roop(i, n) {
		string s;
		cin >> s;
		string d[2];
		roop(i, s.length()) {
			if (s[i] == ',') { d[0] = s.substr(0, i); d[i] = s.substr(i + 1); break; }
		}
		ll swap[2];
		roop(i, 2) {
			swap[i] = stoll(d[i]);
		}
		ll before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	roop(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

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


int main(){
	int w , n;
	int d1 , d2;
	cin >> w >> n;
	vector<int> ans(w+1);
	for(int i=1 ; i<=w ; i++){
		ans[i]=i;
	}
	for(int i=0 ; i<n ; i++){
		scanf("%d,%d" , &d1 , &d2);
		swap(ans[d1] , ans[d2]);
	}
	for(int i=1 ; i<=w ; i++){
		cout << ans[i] << endl; 
	}
	return 0;
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    int ami[n+1];
    for(int i=0;i<n+1;i++){
        ami[i]=i;
    }
    for(int i=0;i<k;i++){
        int a,b;
        char c;
        cin>>a>>c>>b;
        swap(ami[a],ami[b]);
    }
    
    for(int i=1;i<n+1;i++){
        
        
        cout<<ami[i]<<endl;
    }
    
}

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

using namespace std;

int main() {
	int i, j, l, num[31], w, n, a=0, b=0, c;
	char s[5], as[2], bs[2];
	
	cin >> w;
	for (i = 1; i <= w; i++) {
		num[i] = i;
	}
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s;
		for (j = 0; s[j] != ','; j++) {
			as[j] = s[j];
		}
		for (l=j; s[j + 1] != NULL; j++) {
			bs[j - l] = s[j + 1];
		}
		a = atoi(as);
		b = atoi(bs);
		c = num[a];
		num[a] = num[b];
		num[b] = c;
	}
	for (i = 1; i <= w; i++) {
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <iostream>

const int W_MAX = 30;
const int N_MAX = 30;

int w;
int n;
int a[N_MAX + 1];
int b[N_MAX + 1];
int out[W_MAX + 1];

void chenge(int *farst, int *second){
	int tmp;
	tmp = *farst;
	*farst = *second;
	*second = tmp;
}

int main(void){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	std::cin >> w;
	std::cin >> n;

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

	for(int i = 1; i <= n; i++){
		std::cin >> a[i] >> b[i];
		chenge(&out[a[i]], &out[b[i]]);
	}
	
	for(int i = 1; i <= w; i++){
		std::cout << out[i] << ' ';
	}

	std::cout << '/n';

	return 0;
}

C++: #include<iostream>

using namespace std;

int map[30][31];
int w,n;

void search(int s_x,int x,int y)
{
/*	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<w;j++)
		{
			cout << map[j][i] << " " ;
		}
		cout << endl;
	}
	
	getchar();
	system("cls");
*/	
	if(y==n)
	{
		map[x][n]=s_x+1;
		return ;
	}
	
	if(map[x][y]!=100)
		x=map[x][y];
	
	search(s_x,x,y+1);
}

int main()
{
	int a1,b1;
	int i,j;
	char a;
	
	cin >> w ;
	cin >> n ;
	
	for(i=0;i<=n;i++)
		for(j=0;j<w;j++)
			map[j][i]=100;
	
	for(i=0,j=0;i<n;i++,j++)
	{
		cin >> a1 >> a >> b1 ;
		map[a1-1][j]=b1-1;
		map[b1-1][j]=a1-1;
	}
	
/*	for(i=0;i<=n;i++)
	{
		for(j=0;j<w;j++)
		{
			cout << map[j][i] << " " ;
		}
		cout << endl;
	}
	
	getchar();
	system("cls");
*/	
	for(i=0;i<w;i++)
	{
		search(i,i,0);
	}
	
	for(i=0;i<w;i++)
	{
		cout << map[i][n] << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
inline int nextInt(void){
	int res=0;
	char ch=getchar();
	while(ch>'9'||ch<'0')
		ch=getchar();
	while(ch<='9'&&ch>='0'){
		res=res*10+ch-'0';
		ch=getchar();
	}
	return res;
}
signed main(void){
	int n=nextInt(),m=nextInt();
	int ans[n+1];
	for(int i=1;i<=n;i++)
		ans[i]=i;
	for(int i=1;i<=m;i++)
		swap(ans[nextInt()],ans[nextInt()]);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
}

C++: #include<iostream>

using namespace std;

int main() {
	int i, j, l, num[31], w, n, a=0, b=0, c;
	char kanma;
	
	cin >> w;
	for (i = 1; i <= w; i++) {
		num[i] = i;
	}
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a >> kanma >> b;
		c = num[a];
		num[a] = num[b];
		num[b] = c;
	}
	for (i = 1; i <= w; i++) {
		cout << num[i] << endl;
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define llong long long

int main() {
  int w,n;
  scanf("%d %d", &w, &n);
  int data[w+1];
  REP(i,w+1){
    data[i] = i;
  }
  REP(i,n) {
    int a,b;
    scanf("%d,%d", &a, &b);
    swap(data[a],data[b]);
  }
  FOR(i,1,w+1) {
    printf("%d\n",data[i]);
  }
  return 0;
}

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