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	<cstdio>
#include	<cmath>

using namespace std;

int main(void) {
	while(1) {
		int w, n;
		int lin[30][2] = { 0 };
		int ans[30];
		int now;
		
		cin >> w;
		if( cin.eof() )		break;
		cin >> n;
		for(int i = 0; i < n; i++) {
			scanf("%d,%d", &lin[i][0], &lin[i][1]);
		}
		for(int i = 1; i <= w; i++) {
			now = i;
			for(int j = 0; j < n; j++) {
				if(now == lin[j][0]) {
					now = lin[j][1];
				} else if(now == lin[j][1]) {
					now = lin[j][0];
				}
			}
			ans[now - 1] = i;
		}
		for(int i = 0; i < w; i++) {
			cout << ans[i] << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <deque>
#include <string>
#include <cstdio>
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,n) loop(i,0,n)

using namespace std;

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

    int vec[40];
    for (int i = 0; i < 40; i++)vec[i] = i;
    for (int i = 0; i < n; i++){
        int a, b;
        char com;
        cin >> a >> com >> b;
        int t = vec[a];
        vec[a] = vec[b];
        vec[b] = t;
    }
    for (int i = 1; i <= w; i++){
        cout << vec[i] << endl;
    }
}

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

void swap(int a[],int x,int y){
  int t=a[x];
  a[x]=a[y];
  a[y]=t;
  return;
}

int main(){
  int a[100]={};
  int n,w;
  cin>>w>>n;
  for(int i=1;i<=w;i++){
    a[i]=i;
  }
  for(int i=0;i<n;i++){
    int e,f;
    scanf("%d,%d",&e,&f);
    swap(a,e,f);
  }
  for(int i=1;i<=w;i++){
    cout<<a[i]<<endl;
  }
}

C++: #include <iostream>

using namespace std;

void swap(int &x,int &y);
int main(){
  int *line=NULL,w,n;
  
  cin>>w;
  cin>>n;

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

void swap(int &x,int &y){
  x^=y;
  y^=x;
  x^=y;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    int w, n, a, b;
    char c;
    cin >> w >> n;
    vector<int> v(w);
    for (int i = 0; i < w; i++) {
        v[i] = i+1;
    }
    for (int i = 0; i < n; i++) {
        cin >> a >> c >> b;
        a--; b--;
        swap(v[a], v[b]);
    }
    for (int &x: v) {
        cout << x << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(0);
	int w; cin >> w;
	vector<int> v(w); REP(i, w) v[i] = i+1;
	int n; cin >> n;
	REP(i, n) {
		int a, b;
		scanf("%d,%d", &a, &b); --a, --b;
		swap(v[a], v[b]);
	}
	REP(i, w) {
		cout << v[i] << endl;
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int w,n,a[100],b,c;
	char z;
	cin>>w>>n;
	for(int i=0;i<w;i++)
		a[i]=i+1;
	for(int i=0;i<n;i++){
		cin>>b>>z>>c;
		int tmp=a[b-1];
		a[b-1]=a[c-1];
		a[c-1]=tmp;
	}
	for(int i=0;i<w;i++)
		cout<<a[i]<<endl;
	return 0;
}

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

int main()
{
 int x[30];
 int w, n;
 
 cin >> w >> n;
 for(int i=0; i<w; i++) x[i] = i+1;

 int a, b;
 for(int i=0; i<n; i++){
  cin  >> a >> b;
  int tmp = x[a];
  x[a] = x[b];
  x[b] = tmp;
 }

 for(int i=0; i<w; i++){
  cout << x[i];
  if(i == w-1) break;
  cout << '\n';
 }

 return 0;
}

C++: #include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <string>
#include <iomanip>
#include <math.h>
#include <limits>
#include <chrono>

using namespace std;

class amida
{
	int w;
	vector<int> va;
public:
	amida(int _w) : w(_w){
		for(int i = 0; i < w; i++){
			va.push_back(i);
		}
	}
	void swap(int, int);
	void output();
};

void amida::swap(int a1, int b1)
{
	int temp = va[a1-1];
	va[a1-1] = va[b1-1];
	va[b1-1] = temp;
}

void amida::output()
{
	for(int i = 0; i < w; i++)
		cout << va[i]+1 << '\n';
}

int main()
{
	int w, n;
	int a1, b1;
	cin >> w;
	amida am(w);
	cin >> n;
	for(int i = 0; i < n; i++){
		string str;
		cin >> str;
		const char* chtemp = str.c_str();
		a1 = atoi(strtok((char*)chtemp, ","));
		b1 = atoi(strtok(NULL, ","));
		am.swap(a1, b1);
	}
	am.output();

	return 0;
}

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

#include <vector>
#include <algorithm>

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_each(intersection.rbegin(), intersection.rend(),
				[&](const auto& x){
					if(x.first == r){
						r = x.second;
					}else if(x.second == r){
						r = x.first;
					}
				}
		);
		cout << r << endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int w,n;
int num[30];
int main(){
    scanf("%d%d",&w,&n);
    for(int i=0;i<w;i++)num[i]=i;
    while(n--){
        int a,b;
        scanf("%d,%d",&a,&b);
        swap(num[--a],num[--b]);
    }
    for(int i=0;i<w;i++)printf("%d\n",num[i]+1);

    return 0;
}

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

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

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

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