Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func swap(ints []int, i, j int) {
	ints[i], ints[j] = ints[j], ints[i]
}

func main() {
	w := nextInt()
	// println(w)
	nums := make([]int, w)
	for i := range nums {
		nums[i] = i+1
	}
	n := nextInt()
	// println(n)
	for i := 0; i < n; i++ {
		info := nextString()
		// println(info)
		infos := strings.Split(info, ",")
		a, _ := strconv.Atoi(infos[0])
		b, _ := strconv.Atoi(infos[1])
		swap(nums, a-1, b-1)
	}
	for _, v := range nums {
		fmt.Println(v)
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
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;
	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);

			//????????¶?????§??????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 < (signed) text.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<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
using namespace std;

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

C++: #include <iostream>

using namespace std;

int main()
{
    int w, n;
	char dummy;
    cin>>w;
	cin>>n;
	int *data = new int [w];
	int *a = new int [n];
	int *b = new int [n];
	for(int i=0;i<n;++i)
	{
		cin>>a[i]>>dummy>>b[i];
	}
	for(int i=0;i<w;++i)
	{
		data[i]=i+1;
	}
	for(int i=0;i<n;++i)
	{
		swap(data[a[i]-1],data[b[i]-1]);
	}
	for(int i=0;i<w;++i)
	{
		cout<<data[i]<<endl;
	}
}

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

int main(){
	int w;
	while(cin>>w){
		vector<pair<int, int> > all;
		int n;
		cin>>n;
		for(int i=0; i<n; i++){
			int a, b;
			scanf("%d,%d", &a, &b);
			cout<<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;


void exchange( int& x, int& y )
{
    int tmp;

    tmp = x;
    x = y;
    y = tmp;
}

int main()
{
    int w, n;                           //w縦線の数, n横線の数

    cin >> w;
    cin >> n;

    int vline[w];                       //縦線を格納する配列

    for( int i = 0; i < w; i++ )        //引数0から1,2,3という数字が入る
    {
        vline[i] = i + 1;
    }

    for( int i = 0; i < n; i++ )
    {
        int from, to;                   //fromからtoへ。int型のみ受け付けたい。
        char extra;                      //','は余分な入力

        cin >> from >> extra >> to;

        exchange( vline[from-1]  , vline[to-1] );
    }

    for( int i = 0; i < w; i++)
        cout << vline[i] << endl;

    return 0;

}

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

#define MAX_N 30
#define MAX_W 30

void swap(int* a, int* b){
    int temp=0;
    temp = *a;
    *a = *b;
    *b = temp;
}

int main(){
    int w,n,ans[MAX_W];
    int a[MAX_N], b[MAX_N];

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

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

    // Solve
    for(int i = 0; i < n; i++){
        swap(&ans[ a[i] - 1 ], &ans[ b[i] - 1 ]);
    }

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



    return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int w, n;
  cin >> w >> n;
  vi v(w);
  iota(all(v), 1);
  rep(i, n) {
    int a, b;
    char gomi;
    cin >> a >> gomi >> b;
    a--;
    b--;
    swap(v[a], v[b]);
  }
  rep(i, w) cout << v[i] << endl;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int bow, n, number[30]={}, a, b;
    char commma;
    cin >> bow >> n;
    for(int i=1; i<=bow; i++){
        number[i]=i;
    }
    for(int i=0; i<n; i++){
        cin >> a >> commma >> b;
        int tmp=number[a];
        number[a]=number[b];
        number[b]=tmp;
    }
    for(int i=1; i<=bow; i++){
        cout << number[i] << endl;
    }
    return 0;
}

C++: 
//Nayeem Shahriar Joy ,Applied Physics And Electronic Engineering , University of Rajshahi.


#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<string>

using namespace std;

int main()

{

  ios_base::sync_with_stdio(false);

  cin.tie(NULL);

  int T,n,x,b,w;

  char s;

  cin>>w;

  int a[w];

  for(int i=0;i<w;i++)

  {
      a[i]=i+1;
  }

  cin>>n;

  while(n--)

  {
      cin>>x>>s>>b;

      swap(a[x-1],a[b-1]);

  }

   for(int i=0;i<w;i++)

   {
       cout<<a[i]<<endl;
   }


  return 0;

}