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 <stdio.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;


int main(void){

	int w, n;
	int left[30] = {}, right[30] = {};
	int ans[30] = {};
	scanf("%d%d", &w, &n );
	for( int i = 0; i < n; i++ ) {
		scanf("%d,%d", left + i, right + i);
		left[i] --;
		right[i] --;
	}
	for( int i = 0; i < w; i++ ) {
		int tmp = i;
		for( int j = 0; j < n; j++ ) {
			if( tmp == left[j] )
				tmp = right[j];
			else if( tmp == right[j] )
				tmp = left[j];
		}
		ans[tmp] = i + 1;
	}
	for( int i = 0; i < w; i++ )
		cout << ans[i] << endl;


    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int w, n, a, b, num[31], store;
    
    cin >> w;
    cin >> n;
    
    for(int i = 1; i <= w; i++){
        num[i] = i;
    }
    
    for(int i = 1; i <= n; i++){
        scanf("%d, %d", &a, &b);
        swap(num[a], num[b]);
    }
    for(int i = 1; i <= w; i++){
        cout << num[i] << endl;
    }
}

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

C++: #include<iostream>
#include<vector>
 
int main()
{
    int w,n;
 
    char c;
 
  cin >> w >> n;
 
 vector<int> a(n);
 
    vector<int> b(n);
 
    vector<int> x(w);
 
    for(int i=0;i<n;i++)
    {
        std::cin >> a[i] >> c >> b[i];
    }
 
    for(int i=0;i<w;i++)
    {
        x[i]=i+1;
    }
 
    for(int i=0;i<n;i++)
    {
        int temp = x[a[i]-1];
 
        x[a[i]-1]=x[b[i]-1];
 
        x[b[i]-1]=temp;
    }
 
    for(int i=0;i<w;++i)
    {
      cout << x[i] << endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_W = 30;
int w, n;
int a, b;
int shff[MAX_W];

int main()
{
  cin >> w >> n;

  rep(i, w) shff[i] = i;
  rep(i, n){
    scanf(" %d,%d", &a, &b);
    swap(shff[a-1], shff[b-1]);
  }

  rep(i, w) cout << shff[i] + 1 << endl;

  return 0;
}

C++: #include<iostream>
using namespace std;
void myswap(int *,int *);
int main(void){
	int abc[31],tate,yoko;
	cin>>tate>>yoko;
	for(int i=1;i<=tate;i++){
		abc[i]=i;
	}
	int pro1,pro2;
	char doll;
	for(int i=1;i<=yoko;i++){
		cin>>pro1>>doll>>pro2;
		myswap(&abc[pro1],&abc[pro2]);
	}
	for(int i=1;i<=tate;i++){
		cout<<abc[i]<<endl;
	}
	return 0;
}
void myswap(int *a,int *b){
	int c;
	c=*a;
	*a=*b;
	*b=c;
}

C++: #include<iostream>

using namespace std;
int data[40];
int main(){

	for(int i=0;i<40;i++)data[i]=i;
	int w;
	int n;
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		char tmp[3];
		cin>>tmp;
		int a=tmp[0]-'0';
		int b=tmp[2]-'0';
		for(int i=1;i<=w;i++){
			if(i==b){
				int tmp=data[a];
				data[a]=data[b];
				data[b]=tmp;
			}
		}
	}
	
	for(int i=1;i<=w;i++)cout<<data[i]<<endl;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int W,N;

int main()
{
	scanf("%d%d",&W,&N);
	vector<int> A(W + 1);
	for(int i = 1;i <= W;i++){
		A [i] = i;
	}

	FOR(i,0,N){
		int x,y;
		char c;
		scanf("%d%c%d",&x,&c,&y);
		swap(A [x],A [y]);
	}
	for(int i = 1;i <= W;i++){
		printf("%d\n",A [i]);
	}

	return 0;
}

C++: #include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

pair<int, int> p;
int a[31];

int main()
{
	int w, n, r;
	cin >> w >> n;
	for (int i = 1; i < w + 1; i++)
		a[i] = i;
	for (int i = 0; i < n; i++)
	{
		scanf("%d,%d", p.first, p.second);
		r = a[p.first];
		a[p.first] = a[p.second];
		a[p.second] = r;
	}
	for (int i = 1; i < w + 1; i++)
	{
		cout << a[i] << endl;
	}
	return 0;
}

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

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

C++: #include <cstdio>

int main()
{
    int amida[33];
    for (int i = 0; i <= 31; ++i)
        amida[i] = i;
    int w, n;
    int a, b;
    std::scanf("%d %d", &w, &n);
    for (int i = 0; i < n; ++i) {
        std::scanf("%d,%d", &a, &b);
        amida[32] = amida[a];
        amida[a] = amida[b];
        amida[b] = amida[32];
    }
    for (int i = 1; i <= w; ++i)
        std::printf("%d\n", amida[i]);
}

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

using namespace std;

int main() {

	int w;
	int n;
	int number[30] = {0};
	int kari;
	int a, b;
	char c;

	cin >> w;
	cin >> n;

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

	for(int i = 0; i < n; i++) {
		cin >> a >> c >> b;
		kari = number[a-1];
		number[a-1] = number[b-1];
		number[b-1] = kari;
	}

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

	return 0;
}

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

int main() {
    int w,n;
    cin >> w;
    cin >> n;

    int a[30];
    for (int i = 0; i < w; ++i) {
        a[i] = i + 1;
    }

    while (n--) {
        int i,j;
        scanf("%d,%d", &i, &j);
        swap(a[i-1], a[j-1]);
    }

    for (int i = 0; i < w; ++i) {
        cout << a[i] << "\n";
    }

    return 0;
}

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


int main(void)
{
	int w,n;

	cin >> w >> n;

	int d[31];
	for(int i = 0; i < 31; i++)
		d[i] = i;
	int a,b;

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


	return 0;
}