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>
using namespace std;

void swap(int &a, int &b){
	int t;
	t = a;
	a = b;
	b = t;
}

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

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	long long w,n;
	string s;
	cin >> w >> n;
	long long ans[w];
	for(int i=0;i<w;i++){
		ans[i]=i+1;
	}
	for(int i=0;i<n;i++){
		cin >> s;
		for(int j=0;j<s.size();j++){
			if(s[j]==','){
				string ss=s.substr(0,j),tt=s.substr(j+1,s.size()-j-1);
				swap(ans[atoi(ss.c_str())-1],ans[atoi(tt.c_str())-1]);
			}
		}
	}
	for(int i=0;i<w;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

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

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

	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int w,n;
	cin >> w >> n;
	vector<pair<int,int>> v;
	rep(i,0,n){
		int a,b;
		scanf("%d,%d",&a,&b);
		a--;
		b--;
		v.push_back(pair<int,int> (a,b));
	}
	
	int ans[w];

	rep(i,0,w){
		int now = i;
	
		rep(j,0,n){
			//cout << now << " " << v[j].first << " " << v[j].second << endl;
			if( v[j].first == now )
				now = v[j].second;
			else if( v[j].second == now)
				now = v[j].first;
		}
		
		ans[now] = i+1;
		
		//cout << "now:" <<  now+1 << endl;
	}
	
	rep(i,0,w)
		cout << ans[i] << endl;

	ret 0;
}

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

int main(int argc, const char * argv[])
{
    int w, n;
    
    cin >> w;
    cin >> n;
    
    int ary[w];
    for (int i=1; i<=w; i++) {
        ary[i-1] = i;
    }
    
    for (int i=0; i<n; i++) {
        int a, b;
        scanf("%d,%d",&a, &b);
        swap(ary[a-1], ary[b-1]);
    }

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

    return 0;
}

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

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

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

    int lots[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 i=0; i<w; i++) cout << lots[i] << endl;

    return 0;
}

C++: #include<stdio.h>

int main(){
	int tate,yoko,bou[40][2],j,x,kekka[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30},i=0;
	scanf("%d %d",&tate,&yoko);
	for(j=0;j<yoko;j++){
		scanf("%d",&bou[j][1]);
		printf(",");
		scanf("%d",&bou[j][2]);
	}
	for(i=1;i<tate+1;i++){
		x=i;
		for(j=0;j<yoko;j++){
			if(bou[j][1]==x){
				x=bou[j][2];
			}
			else if(bou[j][2]==x){
				x=bou[j][1];
			}
		}
		kekka[x-1]=i;
	}
	for(j=0;j<tate;j++){
		printf("%d\n",kekka[j]);
	}
return 0;
}

C++: #include <stdio.h>
int main(){
    int n,m,x,y,a[31];
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)a[i]=i;
    for(int i=0;i<m;i++){
        scanf("%d,%d",&x,&y);
        a[0]=a[x];
        a[x]=a[y];
        a[y]=a[0];
    }
    for(int i=1;i<=n;i++){
        printf("%d\n",a[i]);
    }
}