Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	lines, _ := strconv.Atoi(sc.Text())
	l := make([]int, lines)
	for i := 0; i < lines; i++ {
		l[i] = i + 1
	}

	sc.Scan()
	rows, _ := strconv.Atoi(sc.Text())
	for i := 0; i < rows; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), ",")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])

		l[a-1], l[b-1] = l[b-1], l[a-1]
	}
	for _, j := range l {
		fmt.Println(j)
	}
}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
#include <sstream>

using namespace std;
typedef pair<int,int> P;
vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

int main(){
  int w,n;
  cin>>w;
  cin>>n;
  int ami[40];
  P bou[40];
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    vector<string> tmp=split(s,',');
    int x=0,y=0;
    int h=1;
    for(int j=0;j<tmp[0].size()-1;j++)h*=10;
    for(int j=0;j<tmp[0].size();j++){
      x+=(tmp[0][j]-48)*h;
      h/10;
    }
    h=1;
    for(int j=0;j<tmp[1].size()-1;j++)h*=10;
    for(int j=0;j<tmp[1].size();j++){
      y+=(tmp[1][j]-48)*h;
      h/=10;
    }
    bou[i]=P(x,y);
  }
  for (int i=0;i<w;i++){
    int start=i+1;
    for(int j=0;j<n;j++){
      if(bou[j].first==start){start=bou[j].second;}
      else if(bou[j].second==start){start=bou[j].first;}
    }
    ami[start]=i+1;
  }
  for(int i=1;i<=w-1;i++)cout<<ami[i]<<" ";
  cout<<ami[w]<<endl;






}

C++: #include "bits/stdc++.h"
using namespace std;

int main() {
	int W, N;
	vector<int> V;
	cin >> W >> N;
	for (int i = 1; i <= W; i++) {
		V.push_back(i);
	}
	for (int i = 0; i < N; i++) {
		int A, B;
		char C;
		cin >> A >> C >> B;
		A--, B--;
		swap(V[A], V[B]);
	}
	for (int i = 0; i < W; i++) {
		cout << V[i] << endl;
	}
}

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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int w, n;
	cin >> w >> n;
	vector<int> Pos(w + 1);
	vector<P> Vec(n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d,%d", &Vec[i].first, &Vec[i].second);
	}
	for(int i = 1; i <= w; ++i)
	{
		int pos = i;
		for(int j = 0; j < n; ++j)
		{
			if(Vec[j].first == pos)
			{
				pos = Vec[j].second;
			}
			else if(Vec[j].second == pos)
			{
				pos = Vec[j].first;
			}
		}
		Pos[pos] = i;
	}
	for(int i = 1; i <= w; ++i)
	{
		cout << Pos[i] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <bits/stdc++.h>
#include <chrono>
using namespace std;

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define endl "\n"

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 w, n, a, b; vector<_i64> list;
        scanf("%ld", &w); list.resize(w); iota(_all(list), 1);
        scanf("%ld", &n);
        _rep(i, n) {
            scanf("%ld,%ld", &a, &b);
            swap(list[a - 1], list[b - 1]);
        }
        _foreach(e, list) { printf("%ld\n", e); }
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int main(){
  vector<int> lot;
  int n,m;
  cin >>n>>m;
  for(int i=1; i<=n; i++) lot.push_back(i);
  for(int i=0,a,b; i<m; i++){
    scanf("%d,%d",&a,&b);
    int c = lot[a-1];
    lot[a-1] = lot[b-1];
    lot[b-1] = c;
  }
  for(int i=0; i<n; i++) cout <<lot[i]<<endl;
  return 0;
}

C++: #include<iostream>
#include<vector>
#include <stdio.h>
int main(){
	int w;
	std::cin>>w;
	std::vector<int> a(w);
	for(int i=1;i<=w;i++)a[i]=i;
	int n;
	std::cin>>n;
	while(n>0){
		int b,c;
		scanf("%d,%d",&b,&c);
		//std::cin>>b>>c;
		int d=a[b];
		a[b]=a[c];
		a[c]=d;
		n--;
	}
	for(int i=1;i<=w;i++)std::cout<<a[i]<<std::endl;
	return 0;
}

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

#include <cmath>

#include <vector>

using namespace std;

int main(void)
{
	int w, n;

	cin >> w;
	cin >> n;

	vector<pair<int, int>> intersection(n);

	for(int i = 0; i < n; i++){
		scanf("%d,%d", &intersection[i].first, &intersection[i].second);
	}

	for(int i = 1; i <= w; i++){
		int r = i;
		for(const auto& x : intersection){
			if(x.first == r){
				r = x.second;
				break;
			}
			if(x.second == r){
				r = x.first;
				break;
			}
		}
		cout << r << endl;
	}

	return 0;
}

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

int main()
{

	int w, n;
	cin >> w >> n;
	int A[30];
	for (int i = 0; i < w; i++) {
		A[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		int a, b;
		char kannma;
		cin >> a >> kannma >> b;
		swap(A[a - 1], A[b - 1]);
	}
	for (int i = 0; i < w; i++) {
		cout << A[i] << endl;
	}
	return 0;
}

C++: #include <iostream>

const int W_MAX = 30;
const int N_MAX = 30;

int w;
int n;
int a[N_MAX + 1];
int b[N_MAX + 1];
int out[W_MAX + 1];

void chenge(int *farst, int *second){
	int tmp;
	tmp = *farst;
	*farst = *second;
	*second = tmp;
}

int main(void){
	std::ios_sync_with(false);
	std::cin.tie(0);

	std::cin >> w;
	std::cin >> n;

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

	for(int i = 1; i <= n; i++){
		std::cin >> a[i] >> b[i];
		chenge(&out[a[i]], &out[b[i]]);
	}
	
	for(int i = 1; i <= w; i++){
		std::cout << out[i] << ' ';
	}

	std::cout << '/n';

	return 0;
}