Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5);
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
class Vec2 {
public:
	ld x, y;
	Vec2() { x = 0, y = 0; }
	Vec2(ld x, ld y) :x(x), y(y) {}
	ld length() {
		return sqrt(x*x + y * y);
	}
	void normal() {
		ld len = this->length();
		if (len == 0) return;
		x /= len, y /= len;
	}
	Vec2 operator+(Vec2 vec) {
		return Vec2(x + vec.x, y + vec.y);
	}
	Vec2 operator-(Vec2 vec) {
		return Vec2(x - vec.x, y - vec.y);
	}
	Vec2 operator*(int cons) {
		return Vec2(x*cons, y*cons);
	}
	int operator*(Vec2 vec) {
		return x * vec.x + y * vec.y;
	}
	int operator%(Vec2 vec) {
		return x * vec.y - y * vec.x;
	}
};
int dot(Vec2 a, Vec2 b) {
	return a.x*b.x + a.y*b.y;
}
int cross(Vec2 a, Vec2 b) {
	return a.x*b.y - a.y*b.x;
}
class Vec3 {
public:
	ld x, y, z;
	Vec3() { x = 0, y = 0, z = 0; }
	Vec3(ld x, ld y, ld z) :x(x), y(y), z(z) {}
	ld length() {
		return sqrt(x*x + y * y + z * z);
	}
	void normal() {
		ld len = this->length();
		if (len == 0) return;
		x /= len, y /= len, z /= len;
	}
	Vec3 operator+(Vec3 vec) {
		return Vec3(x + vec.x, y + vec.y, z + vec.z);
	}
	Vec3 operator-(Vec3 vec) {
		return Vec3(x - vec.x, y - vec.y, z - vec.z);
	}
	Vec3 operator*(int cons) {
		return Vec3(x*cons, y*cons, z*cons);
	}
	int operator*(Vec3 vec) {
		return x * vec.x + y * vec.y + z * vec.z;
	}
};
int dot(Vec3 a, Vec3 b) {
	return a.x*b.x + a.y*b.y + a.z*b.z;

}
class Line {
public:
	Vec2 from, to;
	Line(Vec2 from, Vec2 to) :from(from), to(to) {}
};
Line getPerpendicularBisector(Line line) {
	int cx = (line.from.x + line.to.x) / 2, cy = (line.from.y + line.to.y) / 2;
	Vec2 p = Vec2(cx + (line.from.y - line.to.y), cy + (line.to.x - line.from.x));
	return Line(Vec2(cx, cy), p);
}
int a[200];
signed main() {
	int w, n;
	cin >> w >> n;
	for (int i = 1; i <= w; i++) a[i] = i;
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%lld,%lld", &x, &y);
		swap(a[x], a[y]);
	}
	for (int i = 1; i <= w; i++) cout << a[i] << endl;
}

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

int main(){
	int w, n, a, b;
	while(cin>>w){
		vector<pair<int, int> > all;
		cin>>n;
		for(int i=0; i<n; i++){
			scanf("%d,%d", &a, &b);
			all.push_back(pair<int, int>(a, b));
		}
		reverse(all.begin(), all.end());
		for(int i=1; i<=w; i++){
			int ima = i;
			for(int j=0; j<n; j++){
				if(all[j].first == ima) ima = all[j].second;
				else if(all[j].second == ima) ima = all[j].first;
			}
			cout<<ima<<endl;
		}
	}
}

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

int main(){
    int w,n;
    cin>>w>>n;
    int vec[30];
    for(int i=0;i<w;i++)
        vec[i]=i+1;
    for(int i=0;i<n;i++){
        int x,y;char m;
        cin>>x>>m>>y;
        swap(vec[x-1],vec[y-1]);
    }
    for(int i=0;i<w;i++)
        cout<<vec[i]<<endl;
}

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

#define SIZE 30

using namespace std;

int main() {
	int w, n, a, b, temp, node[SIZE];
	cin >> w >> n;

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

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

		temp = node[a - 1];
		node[a - 1] = node[b - 1];
		node[b - 1] = temp;
	}

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

C++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#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(ll a=0;a<t;a++)
int main()
{
	ll w, n;

	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; }
		}
		ll swap[2];
		roop(i, 2) {
			swap[i] = stoll(d[i]);
		}
		ll 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 <iostream>
#include <utility>
#include <cstring>
using namespace std;

void swap(int*,int*,int);
int main()
{
  int w,n,i;
  cin>>w>>n;
  int *numline = new int[w];
  for(i=0;i<w;++i){
    numline[i]=i+1;
  }
  int *swapline = new int[2*n];
  for(i=0;i<2*n;i+=2){
    char innum[10];
    cin >>innum;
    int m=0;
    while(innum[m]!=',') ++m;
    if(m==1){
      swapline[i]=innum[0]-48;
      if(strlen(innum)-m-1==1) swapline[i+1]=innum[2]-48;
      else swapline[i+1]=10*(innum[2]-48)+(innum[3]-48);
    }
    else{
      swapline[i]=10*(innum[0]-48)+(innum[1]-48);
      if(strlen(innum)-m-1==1) swapline[i+1]=innum[3]-48;
      else swapline[i+1]=10*(innum[3]-48)+(innum[4]-48);
    }
  }
  swap(numline,swapline,n);
  for(i=0;i<w;++i){
  cout<<numline[i]<<endl;
  }
  delete[] numline;
  delete[] swapline;
  return 0;
}

void swap(int numline[],int swapline[],int n)
{
  for(int i=0;i<2*n;i+=2){
    swap(numline[swapline[i]-1],numline[swapline[i+1]-1]);
  }
}