Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func swap(ints []int, i, j int) {
	ints[i], ints[j] = ints[j], ints[i]
}

func main() {
	w := nextInt()
	// println(w)
	nums := make([]int, w)
	for i := range nums {
		nums[i] = i+1
	}
	n := nextInt()
	// println(n)
	for i := 0; i < n; i++ {
		info := nextString()
		// println(info)
		infos := strings.Split(info, ",")
		a, _ := strconv.Atoi(infos[0])
		b, _ := strconv.Atoi(infos[1])
		swap(nums, a-1, b-1)
	}
	for _, v := range nums {
		fmt.Println(v)
	}
}

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

C++: #include <iostream>

using namespace std;

int main(){
    int w,n;
    int lots[30];

    cin>>w;
    for (int i=0;i<w;i++){
        lots[i]=i+1;
    }
    cin>>n;
    for (int i = 0; i < n; ++i) {
        int a,b;

        scanf("%d,%d",&a,&b);
        swap(lots[a-1],lots[b-1]);
    }
    for (int j = 0; j < w; ++j) {
        cout<<lots[j]<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for (int i=n;^i;i--)
#define ALL(v) v.begin(),v.end()
// #define int ll 
#define eps 1e-9
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
typedef long long ll;

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

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

#define MAX 30
#define rep(i, a) for(int i = 0; i < (a); ++i)
#define rept(i, a, b) for(int i = (a); i <= (b); ++i)

int main(){
	int w, n;
	int num[MAX];
	int a, b;
	rep(i, n)
		num[i] = i + 1;		
	std::cin >> w >> n;
	rep(i, n){
		scanf("%d,%d", &a, &b);
		std::swap(num[a - 1], num[b - 1]);
	}
	rep(i, w)
		std::cout << num[i] << std::endl;
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    // default
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.ignore(INT_MAX, '\n');
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_b) - 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  } // while loop out
  return 0;
}