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 <string>
#include <vector>
#include <algorithm>
#include <utility>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define INF 2000000000



using namespace std;
int main(void){
    int n,m;
    vector<int> v;
    cin>>n>>m;
    rep(i,0,n){
        v.push_back(i+1);
    }
    
    rep(i,0,m){
        int x,y;
        char c;
        cin>>x>>c>>y;
        x--; y--;
        int swap;
        swap=v[x];
        v[x]=v[y];
        v[y]=swap;
        
    }
    
    rep(i,0,n) cout<<v[i]<<endl;
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <vector>

using namespace std;

void exchange(vector<int> &array, int w, vector<vector <int> > n){

  for(int i=0;i<n.size();i++){
    int a = n[i][0]-1;
    int b = n[i][1]-1;
    //    cout << "a: " << a << ", b: " << b << endl;
    int tmp = array[a];
    array[a] = array[b];
    array[b] = tmp;
  }  
}
  

int main(){

  int w, n;
  cin >> w;
  cin >> n;

  vector<vector <int> > Yoko;
  Yoko.resize(n);
  
  for(int i=0;i<n;i++){
    Yoko[i].resize(2);
    int a, b;
    char c;
    cin >> a >> c >> b;
    Yoko[i][0] = a;
    Yoko[i][1] = b;
  }

  vector<int> array;
  for(int i=0;i<w;i++){
    array.push_back(i+1);
  }
  
  exchange(array, w, Yoko);

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

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

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

    vector<int>a(w+1);
    for(int i=0; i<w+1; i++) a[i] = i;

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

    for(int i=1; i<w+1; i++) cout << a[i] << endl;

    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;
int w;
int line[30][2];
int perm[31];

int main() {
	cin >> n;
	cin >> w;
	for (int i = 0; i < w; i++) {
		string str;
		cin >> str;
		line[i][0] = str[0] - '0';
		line[i][1] = str[2] - '0';
	}

	for (int i = 1; i <= n; i++) {
		int pt = i;
		for (int j = 0; j < w; j++) {
			if (line[j][0] == pt) pt = line[j][1];
			else if (line[j][1] == pt) pt = line[j][0];
		}
		perm[pt] = i;
	}

	for (int i = 1; i <= n; i++) {
		cout << perm[i] << endl;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

C++: #include<iostream>
#include<stdio.h>
#define N 30
using namespace std;
int main(){
  int w,n,tmp;
  int lod[N]; int lis[N][3];
  while(cin >> n >> w){
  for(int i = 0;i<n;i++){
    lod[i] = i+1;
  }
 
  for(int i=0;i<w;i++){
    scanf("%d,%d",&lis[i][0],&lis[i][2]);
  }
  for(int i=0;i<w;i++){
    tmp = lod[lis[i][0]-1];
    lod[lis[i][0]-1] = lod[lis[i][2]-1];
    lod[lis[i][2]-1] = tmp;
  }
  for(int i=0;i<n;i++){
    cout << lod[i] << endl;
  }
  }
}

C++: #include <iostream>
#include <utility>
using namespace System;
using namespace std;
const int MAX_W = 30;
int main()
{
    int w,n;
	int num[MAX_W+1]={};
	char c;
	cin>>w>>n;
	for(int i=0;i<w;i++){
		num[i]=i+1;
	}
	int a,b;
	for(int i=0;i<n;i++){
		cin>>a>>c>>b;
		swap(num[a-1],num[b-1]);
	}
	for(int i=0;i<w;i++){
		cout<<num[i]<<endl;
	}
    return 0;
}

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

using namespace std;

int swap(int nowAt, int a, int b) {
    if (a == nowAt) {
        return b;
    }
    if (b == nowAt) {
        return a;
    }

    return nowAt;
}

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main() {
    int w, n, i, ii, nowAt;

    cin >> w >> n;

    int results[w];

    // ルートの読み込み
    int routes[n][2];
    for (i = 0; i < n; i++) {
        string buffer;
        cin >> buffer;

        vector<string> splitted = split(buffer, ',');
        routes[i][0] = stoi(splitted[0]);
        routes[i][1] = stoi(splitted[1]);
        vector<string>().swap(splitted); // メモリの解放
    }

    // それぞれあみだくじをやる
    for (i = 0; i < w; i++) {
        nowAt = i+1; // 最初の位置

        // あみだの全節を通る
        for (ii = 0; ii < n; ii++) {
            nowAt = swap(nowAt, routes[ii][0], routes[ii][1]);
        }

        results[nowAt-1] = i + 1;
    }

    for(int goal : results) cout << goal << endl;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
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 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++: #include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pb push_back

# define inOut(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
# define RESET(a) memset(a,0,sizeof(a))
# define MEMO(a) memset(a,-1,sizeof(a))
# define DEBUG puts("Debug-Has-Come-Until-Here")


typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	cin.tie(NULL);

	char dummy;
	int T, a,b, arr[35],i,n;
	for (i=1; i<=35; i++) arr[i] = i;
	
	scanf("%d", &n);
	scanf("%d", &T);
	while (T--){
		scanf("%d%c%d", &a,&dummy,&b);
		swap(arr[a], arr[b]);
	}
	for (i=1; i<=n; i++)printf("%d\n", arr[i]);
	
	return 0;
}