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++: /*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

void out1(vector<int> a) {
	for (size_t i = 0; i < a.size(); i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}

int main() {
	int w, n;
	cin >> w;	// ???????????°
	cin >> n;	// ?¨?????????°
	vector<int> begin(n);
	vector<int> end(n);
	vector<int> location(w);
	int num1 = 0;
	int num2 = 0;

	// ??\???
	for (size_t i = 0; i < n; i++)
	{
		scanf("%d,%d", &begin[i], &end[i]);
	}

	// location????????????
	for (size_t i = 0; i < w; i++)
	{
		location[i] = i + 1;
		
	}
	
	// ????????\??¬????????§????????????
	for (size_t i = 0; i < w; i++)
	{
		vector<int> tmp(w,0);
		//out1(tmp);
		tmp[i] = location[i];
		//cout << "----i = " << i << "?????¨???----" << endl;
		for (size_t j = 0; j < n; j++)
		{
			if (begin[j] == location[i])
			{
				
				//cout << begin[j] << "???" << end[j] << "?????\???????????????" << endl;
				location[i] = end[j];
			}
			else if (end[j] == location[i])
			{
				//cout << end[j] << "???" << begin[j] << "?????\???????????????" << endl;
				location[i] = begin[j];
			}
			//out1(location);
		}
	}
	// ???????????????
	vector<int> output(w,0);
	for (size_t i = 0; i < w; i++)
	{
		output[location[i]-1] = i;
	}

	// ???????????¨???????????????????????°??????1????¶????
	for (size_t i = 0; i < w; i++)
	{
		cout << output[i]+1 << endl;
	}


	return 0;
}

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

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

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

int main(){
int w = 0;
cin >> w ;
int n = 0;
cin >> n;
int i = 1;
int a[w];
for(i = 0,i < w,i++){
a[i] = i + 1;
}
for(i = 1,i <= n,i++){
int aa = 0;int bb = 0;
char split;
cin >> aa >> split >> bb ;
int c = 0;
c = a[aa - 1];
a[aa - 1] = a[bb - 1];
a[bb - 1] = c;
}
for(i = 0,i < w, i++){
cout << a[i] << endl;
}
    return 0;
}

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

int main()
{
	int w,n;

	char c;

	std::cin >> w >> n;

	std::vector<int> a(n);

	std::vector<int> b(n);

	std::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)
	{
		std::cout << x[i] << '\n';
	}
}

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

int main()
{
	int n,w,pos[31];


	cin>>w;
	for(int i=0;i<=w;i++) pos[i]=i;
	cin>>n;
	for(int i=0;i<n;i++){
		int left,right;
		string num,str_left,str_right;
		stringstream ss_left,ss_right;
		
		cin>>num;
		int j=0;
		while(num[j] != ','){
			j++;
		}
		str_left=num.substr(0,j);
		ss_left<<str_left;
		ss_left>>left;
		str_right=num.substr(j+1);
		ss_right<<str_right;
		ss_right>>right;
		
	//	cout<<"("<<left<<","<<right<<")"<<endl;

		int temp;
		temp=pos[left];
		pos[left]=pos[right];
		pos[right]=temp;
	}
	for(int i=1;i<=w;i++) cout<<pos[i]<<endl;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

inline bool IN(int x, int y, int w, int h)
{
    return 0 <= x && x < w && 0 <= y && y < h;
}


int main()
{
	int n,w;
	char dummy;
	cin >> n;
	cin >> w;
	vi l(n);
	rp(i,l){
		l[i]=i+1;
	}
	rep(i,w){
		int a,b;
		cin >> a >> dummy >> b;
		swap(l[a-1],l[b-1]);
	}
	rp(i,l){
		cout << l[i] << endl;
	}


}

C++: #include <iostream>
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 <iomanip>
#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_s("%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;
}