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 <stdio.h>

struct path {
	int a ;
	int b ;
} p[33] ;

int w ;
int n ;
int ans[35] ;

int main ( )
{
	while ( scanf ( "%d" , &w ) == 1 ) {
		scanf ( "%d" , &n ) ;
		for ( int i = 0 ; i < n ; i++ ) {
			scanf ( "%d,%d" , &p[i].a , &p[i].b ) ;
			p[i].a-- ;
			p[i].b-- ;
		}
		for ( int i = 0 ; i < w ; i++ ) {
			int tmp = i ;
			for ( int j = 0 ; j < n ; j++ ) {
				if ( tmp == p[j].a ) {
					tmp = p[j].b ;
				}
				else if ( tmp == p[j].b ) {
					tmp = p[j].a ;
				}
			}
			ans[tmp] = i ;
		}
		for ( int i = 0 ; i < w ; i++ ) {
			printf ( "%d\n" , ans[i] + 1 ) ;
		}
	}
	return 0 ;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int d[30];
int main() {
	int w, n; scanf("%d%d", &w, &n);
	rep(i, w)d[i] = i + 1;
	rep(i, n) {
		int a, b; scanf("%d,%d", &a, &b); a--; b--;
		swap(d[a], d[b]);
	}
	rep(i, w)printf("%d\n", d[i]);
}

C++: #include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

void swap(int& x, int& y) {
  int tmp = x;
  x = y;
  y = tmp;
}

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

C++: #include <iostream>
#include <stdio.h>

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){
		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<stdio.h>

void swap(int*, int*);

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

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

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

using namespace std;

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

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

using namespace std;

int main()
{
	int w, n;
	int a, b;
	int data[30][2];
	int data2[30][2];
	int temp;
	int i, j, k;
	int out[30];
	
	cin >> w >> n;
	
	for(i = 0; i < n; i++){
		scanf("%d,%d",&a,&b);
		data[i][0] = a;
		data[i][1] = b;
		
		data2[i][0]=b;
		data2[i][1]=a;
		
	}
	
	for(i = 1; i < w+1; i++){
		temp = i;
		
//		cout << "¡" << temp <<"ÔÚ" << endl;
		
		//ã©çÇ±ÉEÖÚÁ½©©Ä¢­
		for(j = 0; j < n; j++){
			if(data[j][0] == temp){
//				printf("%d,%dð©Â¯½\n",data[j][0],data[j][1]);
				temp = data[j][1];
				break;
			}
			if(data2[j][0] == temp){
//				printf("%d,%dð©Â¯½\n",data2[j][0],data2[j][1]);
				temp = data2[j][1];
				break;
			}
		}
		//ã©ç¶ÖÚÁ½Ì©©Ä¢­
		for(k = j+1; k < n; k++){
			if(data[k][1] == temp){
				temp = data[k][0];
		//		printf("%d,%dð©Â¯½\n",data[k][0],data[k][1]);
				break;
			}
			if(data2[k][1] == temp){
				temp = data2[k][0];
		//		printf("%d,%dð©Â¯½\n",data2[k][0],data2[k][1]);
				break;
			}
		}
		
//		printf("%dÍ%dÖ\n",i,temp);
		out[temp] = i;
	}
	
	for(int i = 1; i < w+1; i++){
		cout << out[i] << endl;
	}
	
}

C++: #include <cstdio>
 #include <algorithm>
using namespace std;
 
 int main(){
 	int array[50];
 	int w,n,a,b;
 
 	for(int i=0 ; i<50 ; i++){
 		array[i] = i;
 	}
 	
 	scanf("%d", &w);
 	scanf("%d", &n);
 	for(int i=0 ; i<n ; i++){
 		scanf("%d,%d", &a, &b);
 		swap( array[a] , array[b] );
 	}
 	for(int i=1 ; i<=w ; i++){
 		printf("%d\n", array[i]);
 	}
 }

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


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

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

using namespace std;

void swap(int *x, int *y){
	int tmp = *x;
	*x = *y;
	*y = tmp;
}

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

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

C++: #include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int arr[32];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int w, n;
    cin >> w >> n;
    for (int i = 1; i <= 30; ++i)
        arr[i] = i;

    for (int i = 1; i <= n; ++i)
    {
        int a, b;
        char c;
        cin >> a >> c >> b;
        //cout << a << " " << b << endl;
        swap(arr[a], arr[b]);
    }

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

    return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
  int num,change,x,y;
  cin>>num;
  cin>>change;
  char c;
  int *now=new int[num+1]; 
  now[0]=0;
  for(int i=1;i<=num;i++) 
    now[i]=i;
  for(int i=0;i<change;i++) {
    cin>>x>>c>>y;
    int tmp=now[x];
    now[x]=now[y];
    now[y]=tmp;
  }
  for(int i=1;i<=num;i++)
    cout<<now[i]<<endl;
  return 0;
}

C++: #include<stdio.h>
int main(void){
	int w,n,x,y,temp;
	int a[31];
	char str[7];
	for(int i = 0; i < 31; i++){
		a[i] = i;
	}
	scanf("%d %d",&w,&n);
	for(int i = 0; i < n; i++){
		gets(str,6);
		if(str[3] == ',')
			str[3] = ' ';
		else
			str[2] = ' ';
		sscanf(str,"%d %d",&x,&y);
		temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

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

C++: #include <iostream>
using namespace std;
int main(void){
    int w,n,t[31][31],a,b,i,j;
    char ch;
    for(i = 0; i < 31; i++){
        for(j = 0; j < 31; j++){
            t[i][j] = j;
        }
    } 
    cin >> w >> n;
    for(i = 1; i <= n; i++){
        cin >> a >> ch >> b;
        t[i][a] = b;
        t[i][b] = a;
    }
    for(j = 1; j <= w; j++){
        a = j;
        for(i = n; i >= 0; i--){
            a = t[i][a];
        }
        cout << a << endl;
    }
}