Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

C++: 
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int w;
	int amida[31];
	int n;
	char aaa;
	cin >> w >> n;
	int a, b, keep;
	for (int i = 1; i <= w; i++) {
		amida[i] = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> a >>aaa>> b;
		keep = amida[a];
		amida[a] = amida[b];
		amida[b] = keep;
	}
	for (int i = 1; i <= w; i++) {
		cout << amida[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include<cstdio>
using namespace std;
int main (){
	int w,N,d[30],c[30];
	int a,b;

	cin>>w>>N;
	for(int j=1;j<=w;j++){
		d[j]=j;
		c[j]=d[j];
	}
	for(int i=0;i<N;i++){
        scanf("%d,%d",&a,&b);
		d[a]=d[b];
		d[b]=c[a];
		c[a]=d[a];
	}
	for(int k=1;k<=w;k++){
	cout<<d[k]<<endl;
	}

	return 0;
}

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

int main()
{
  int w,n;
  int c[50]={0};
  int a,b;
  //  int temp;

  scanf("%d",&w);
  scanf("%d",&n);

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

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

  for(int i=1; i<=w; i++){
    printf("%d\n",c[i]);
  }
}

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

class Amidakuji{

public:
	int W;
	vector<int> array;//????´?1???????????????
	Amidakuji(int w);
	void Swap(int x,int y);
	void call();
};

//????????????????????????????????????
Amidakuji::Amidakuji(int w){

	for (int i = 0; i < w; i++){
		array.push_back(i+1);//[0,1,2,3,4]={1,2,3,4,5}
	}
	
	W = w;

}

void Amidakuji::Swap(int x,int y){

	//???????????£????????????array[]???????????????
	//int?????§???????????£????????§char???int?????????????????????-48;
	
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	

}

void Amidakuji::call(){

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

}

int stoi(string str){
	int ret;
	stringstream ss;
	ss << str;
	ss >> ret;
	return ret;
}

int main(){


	int w, n,loc,a,b,length;
	string text,str_a,str_b,str_v;
	

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);

			length=(int)text.length();
			//????????¶?????§??????10,2??????????????¨??????{1,0,,,2}??????????????¢????????£?????????????????§??????????????????????????????????????????

			//?????????????????????????????????????????????????????§?????????????????£?????????????????\????????????????????£???
			loc=text.find(",", 0);
			str_a = text[0];
			for (int j = 1; j < loc; j++){
				str_v = text[j];
				str_a = str_a + str_v;

			}
			str_b = text[loc + 1];
			for (int j = loc + 2; j < length; j++){
				str_v = text[j];
				str_b = str_b + str_v;
			}

			
			a = stoi(str_a);
			b = stoi(str_b);


			if (a != 0 && b != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(a, b);
				a = b = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}

	return 0;
}

C++: 
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)

int main(void){
    CIN_NO_SYNC;

    int w,n;
    cin >> w >> n;
    int p[31];
    REP(i, w) p[i+1] = i+1;

    REP(i, n){
        int a,b; char c;
        cin >> a >> c >> b;
        swap(p[a], p[b]);
    }
    REP(i, w) printf("%d\n", p[i+1]);

    return 0;
}

C++: #include<iostream>

int listen_lineCount();
void listen_path(int &from,int &to);

class Lots
{
private:
	int *start_goal;
	int verLineNum;
public:
	Lots(const int lineCount);
	~Lots();
	
	void draw_line(const int from,const int to);
	void echo_goalNums();
};

//-------------------------main--------------------------------

int main()
{
	int ver_lineCount=listen_lineCount();
	Lots *inst_lot;
	inst_lot=new Lots(ver_lineCount);
	
	int hor_lineCount=listen_lineCount();
	
	int from,to;
	for(int roop=0;roop<hor_lineCount;roop++)
	{
		listen_path(from,to);
		inst_lot->draw_line(from,to);
	}
	
	inst_lot->echo_goalNums();
	
	delete inst_lot;
	return 0;
}

//--------------------------------------------------------------

Lots::Lots(const int lineCount)
{
	verLineNum=lineCount;
	start_goal=new int(lineCount+1);
	
	for(int roop=1;roop<=lineCount;roop++)
	{
		start_goal[roop]=roop;
	}
}

Lots::~Lots()
{
	delete [] start_goal;
}

void Lots::draw_line(const int from,const int to)
{
	int swap=start_goal[from];
	start_goal[from]=start_goal[to];
	start_goal[to]=swap;
}

void Lots::echo_goalNums()
{
	using namespace std;
	
	for(int roop=1;roop<=verLineNum;roop++)
	{
		cout<<start_goal[roop]<<endl;
	}
}


int listen_lineCount()
{
	using namespace std;
	
	int lineCount;
	cin>>lineCount;
	
	return lineCount;
}

void listen_path(int &from,int &to)
{
	using namespace std;
	
	char delim;//カンマ区切り
	
	cin>>from>>delim>>to;
}

C++: #include<iostream>
#include<stdio.h>

using namespace std;

#define DATA_MAX 50

void swap( int& a , int& b );

int main(void)
{
	int w, n;
	int a, b;

	int data[DATA_MAX];

	cin >> w;
	cin >> n;

	for( int i = 0 ; i < DATA_MAX ; i++ )
	{
		data[i] = i+1;
	}

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

	return 0;
}

void swap( int& a , int& b )
{
	int temp;

	temp = a;
	a = b;
	b = temp;

	return;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef vector<int> vi;

int w,n,a,b;

int main() {
	scanf("%d", &w);
	vi v(w);
	rep(i,w) v[i] = i+1;

	scanf("%d", &n);
	rep(i,n) {
		scanf("%d,%d", &a, &b);
		swap(v[a-1], v[b-1]);
	}

	rep(i,w) printf("%d\n", v[i]);
}