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

C++: #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int w, n; 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	ll a[32];
	roop(i, 32) {
		a[i] = i + 1;
	}
	roop(i, n) {
		string s;
		cin >> s;
		string d[2];
		roop(i, s.length) {
			if (s[i] == ',') { d[0] = s.substr(0, i); d[i] = s.substr(i + 1); break; }
		}
		int swap[2];
		roop(i, 2) {
			swap[i] = stoi(d[i]);
		}
		int before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	roop(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include <algorithm>

#include <stdio.h>

int main(int argc, char** argv)
{
  int w, n;

  fscanf(stdin, "%d", &w);
  
  int ind[30] = { 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
  };

  fscanf(stdin, "%d", &n);
  
  for (int i = 0; i < n; i ++) {
    int a, b;

    fscanf(stdin, "%d,%d", &a, &b);
    
    std::swap(ind[a - 1], ind[b - 1]);
  }
  
  for (int i = 0; i < w; i ++)
    fprintf(stdout, "%d\n", ind[i]);
}