Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	n := nextInt()

	numbers := make([]int, w+1)
	for i := 1; i <= w; i++ {
		numbers[i] = i
	}

	for i := 0; i < n; i++ {
		line := nextString()
		words := strings.Split(line, ",")
		a, _ := strconv.Atoi(words[0])
		b, _ := strconv.Atoi(words[1])

		numbers[a], numbers[b] = numbers[b], numbers[a]
	}

	for i := 1; i <= w; i++ {
		fmt.Println(numbers[i])
	}
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };


int main(){
	ios::sync_with_stdio(false);

	int w, n;
	int a, b;
	char s;

	cin >> w;
	cin >> n;

	vi bar(w);

	REP(i, w)
		bar[i] = i + 1;

	while (n!=0){
		cin >> a >> s >> b;



		swap(bar[a - 1], bar[b - 1]);
		n--;
	}

	REP(i, w)
		printf("%d\n", bar[i]);
}

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

using namespace std;
void lots(int len,int a,int b,int array[]){
    int buffer[len];
    for(int i = 0;i < len; i++){
        if(i == a-1){
            buffer[i] = array[b-1];
        }
        else if(i == b-1){
            buffer[i] = array[a-1];
        }
        else{
            buffer[i] = array[i];
        }
    }
    for(int i = 0; i < len; i++){
        array[i] = buffer[i];
    }

}

int main(){
    int len,duration,a,b;
    cin >> len;
    cin >> duration;
    int array[len];
    for(int i = 0; i < len; i++){
        array[i] = i+1;
    }
    for(int i = 0; i < duration; i++){
        scanf("%d,%d",&a,&b);
        lots(len,a,b,array);
    }
    for(int i = 0; i < len; i++){
        cout << array[i] << endl;
    }
}

C++: w=eval s='gets.to_i';n=eval s;a=[*0..w];n.times{b,c=gets.chop.split(?,).map &:to_i;a[b],a[c]=a[c],a[b]};puts a[1..w]

C++: #include<iostream>
int main(){
	int w,n,a[30][2],b[30];
	std::cin>>w
		>>n;
	for(int i=0;i<n;++i){
			std::cin>>a[i][0]>>','>>a[i][1];
	}
	for(int i=1;i<=w;++i){
		b[i]=i;
	}
	for(int i=0;i<n;++i){
			int x=b[a[i][0]];
			b[a[i][0]]=b[a[i][1]];
			b[a[i][1]]=x;
	}
	for(int i=1;i<=w;++i){
		std::cout<<b[i]<<std::endl;
	}
	return 0;
}

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

int main()
{
	int tmp[30][2];
	int num[30];
	int num2[30];
	int w,n,i,j;
	
	//??????????????????
	for(j=0; j<2; j++){
		for(i=0; i<30; i++){
			tmp[i][j]=0;
			}
	}
	for(i=0; i<30; i++){
		num[i]=1+i;
		num2[i]=1+i;
	}
	
	//????£?w????¨??£?n?????°?????????
	cin >> w >> n;
	
	//?¨??£????????´??????????
	for(i=0; i<n; i++){
		scanf("%d,%d",&tmp[i][0],&tmp[i][1]);
	}
	
	//??\???????????????
	for(i=0; i<w; i++){		//????£??????°????????°?????????
		for(j=0; j<n; j++){		//?¨??£??????°????????°?????????
			//??\?????????
			if((num[i]==tmp[j][0]) || (num[i]==tmp[j][1])){
				if(num[i]==tmp[j][0]){
					num[i]=tmp[j][1];
				}else{
					num[i]=tmp[j][0];
				}		
			}
		}
	}
	for(i=0; i<w; i++){
		j=num[i];
		num2[j-1]=i+1;
	}
	
	
	
	
	//????????¨???
	for(i=0; i<w; i++){
		cout << num2[i] << endl;
	}
	
	return 0;
}

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 <cstdio>
using namespace std;
int w, n, a[31], f, s, t;
int main() {
  for (int i = 0; i < 31; i++) {
    a[i] = i;
  }
  scanf("%d%d", &w, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d,%d", &f, &s);
    t = a[f];
    a[f] = a[s];
    a[s] = t;
  }
  for (int i = 1; i <= w; i++) {
    printf("%d\n", a[i]);
  }
}

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


void swap(int,int);
int ladder[50];
string change;

int main(){
	int v,h,a,b;
	cin >> v >> h;
	for(int i=1;i<=v;i++){
		ladder[i]= i;
	}
	for(int i=1;i<=h;i++){
		cin >> change;
		//cout << change[2];
		change.replace(change.find(","),1," ");
		//tmp.replace(tmp.find(","),1," ");
		istringstream ss(change);
		ss >> a >> b;

		//temp = ladder[b];
		//ladder[b] = ladder[a];
		//ladder[a] = temp;
//		cout << ladder[a] << ladder[b] << endl;
	//	cout << endl << endl;
		swap(a,b);
		/*for(int i=1;i<=v;i++){
			cout << ladder[i] << endl;
		}
		cout << endl;*/
		//	cout << ladder[change[0]] << "-"<<ladder[change[2]] << endl;
	}
//	cout <<endl;

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

void swap(int a,int b){
	int temp;
	temp = ladder[b];
	ladder[b] = ladder[a];
	ladder[a] = temp;
	/*cout << ladder[a] << ladder[b] << endl;
	cout << endl << endl;*/
}

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

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

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