Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	n := nextInt()

	numbers := make([]int, w+1)
	for i := 1; i <= w; i++ {
		numbers[i] = i
	}

	for i := 0; i < n; i++ {
		line := nextString()
		words := strings.Split(line, ",")
		a, _ := strconv.Atoi(words[0])
		b, _ := strconv.Atoi(words[1])

		numbers[a], numbers[b] = numbers[b], numbers[a]
	}

	for i := 1; i <= w; i++ {
		fmt.Println(numbers[i])
	}
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

inline bool IN(int x, int y, int w, int h)
{
    return 0 <= x && x < w && 0 <= y && y < h;
}


int main()
{
	int n,w;
	char dummy;
	cin >> n;
	cin >> w;
	vi l(n);
	rp(i,l){
		l[i]=i+1;
	}
	rep(i,w){
		int a,b;
		cin >> a >> dummy >> b;
		swap(l[a-1],l[b-1]);
	}
	rp(i,l){
		cout << l[i] << endl;
	}


}

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

int main()
{
	int tmp[30][2];
	int num[30];
	int num2[30];
	int w,n,i,j;
	
	//??????????????????
	for(j=0; j<2; j++){
		for(i=0; i<30; i++){
			tmp[i][j]=0;
			}
	}
	for(i=0; i<30; i++){
		num[i]=1+i;
		num2[i]=1+i;
	}
	
	//????£?w????¨??£?n?????°?????????
	cin >> w >> n;
	
	//?¨??£????????´??????????
	for(i=0; i<n; i++){
		scanf("%d,%d",&tmp[i][0],&tmp[i][1]);
	}
	
	//??\???????????????
	for(i=0; i<w; i++){		//????£??????°????????°?????????
		for(j=0; j<n; j++){		//?¨??£??????°????????°?????????
			//??\?????????
			if((num[i]==tmp[j][0]) || (num[i]==tmp[j][1])){
				if(num[i]==tmp[j][0]){
					num[i]=tmp[j][1];
				}else{
					num[i]=tmp[j][0];
				}		
			}
		}
	}
	for(i=0; i<w; i++){
		j=num[i];
		num2[j-1]=i+1;
	}
	
	
	
	
	//????????¨???
	for(i=0; i<w; i++){
		cout << num2[i] << endl;
	}
	
	return 0;
}

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

pair<int, int> p;
int a[31];

int main()
{
	int w, n, r;
	cin >> w >> n;
	for (int i = 1; i < w + 1; i++)
		a[i] = i;
	for (int i = 0; i < n; i++)
	{
		scanf_s("%d,%d", &p.first, &p.second);
		r = a[p.first];
		a[p.first] = a[p.second];
		a[p.second] = r;
	}
	for (int i = 1; i < w + 1; i++)
	{
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void) {
  int i, n, j, k, w;
  scanf("%d%d", &w, &n);
  int a[n], b[n], now, ans[w + 2];
  for(i = 0; i < n; ++i) scanf("%d,%d", &a[i], &b[i]);
  for(i = 1; i <= w; ++i) {
    now = i;
    for(j = 0; j < n; ++j) {
      if(a[j] == now) now = b[j];
      else if(b[j] == now) now = a[j];
    }
    ans[now] = i;
  }
  for(i = 1; i <= w; ++i) printf("%d\n", ans[i]);
  return 0;
}

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

inline void change(int array[], int a, int b){
  int c = array[a];
  array[a] = array[b];
  array[b] = c;
}

int main(){
  int array[MAX];
  int w, n, a, b;
  char comma;

  cin >> w >> n;

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

  for(int i=0; i<n; i++){
    cin >> a >> comma >> b;
    change(array, a-1, b-1);
  }

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

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

int main(){

	int w, n;
	int num[30] = { 0 };
	int a, b;
	char c;

	cin >> w;
	cin >> n;

	for (int i = 0; i<w; i++)
		num[i] = i + 1;

	for (int i = 0; i<n; i++){

		cin >> a >> c >> b;


		int tmp = num[a-1];
		num[a-1] = num[b-1];
		num[b-1] = tmp;


	}


	for (int i = 0; i<w; i++)
		cout << num[i] << "\n";

	return 0;

}

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

int main() {
  int w, n;
  cin >> w >> n;
  int a[n], b[n];

  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    a[i] = s[0] - '1'; b[i] = s[2] - '1';
  }
  for (int i=0; i<w; i++) {
    int p = i;
    for (int j=n-1; j>=0; j--) {
      if (p == a[j])
        p = b[j];
      else if (p == b[j])
        p = a[j];
    }
    cout << p + 1 << endl;
  }
}

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

C++: #include<iostream>
using namespace std;
void swap(int* a,int* b){
	int t=*a;
	*a=*b;
	*b=t;
	}
int main(){
	int w;
	int n;
	int c[30];
	int a;
	int b;
	scanf("%d",&w);
	scanf("%d",&n);
	for(int i=0;i<=w;i++){
		c[i]=i;
		}
	for(int i=0;i<n;i++){
		(cin>>a).ignore()>>b;
        swap(c[a],c[b]);
       }
     for(int i=1;i<=w;i++){
     	cout<<c[i]<<endl;
     }
     return 0;
    }

C++: #include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

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

C++: #include <iostream>
#include <vector>
//#include <math.h>
//#include <string>
#include <cmath>
#include <iomanip>

int main();

//最初に素数リストを作成し、入力された値に対してリストを参照する。
int main(){
	int w;		//縦線の本数
	int n;		//横棒の本数
	int lines[31];		//ライン番号

	std::cin >> w >> n;
	
	//ライン番号初期化
	//範囲に注意
	for (int i = 1; i <= w; i++){
		lines[i] = i;
	}
	for (int i = 0; i < n; i++){
		int x;
		int y;
		char comma;

		std::cin >> x >> comma >> y;
		//交換処理
		int temp;
		temp = lines[x];
		lines[x] = lines[y];
		lines[y] = temp;
	}
	//結果出力
	//範囲に注意
	for (int i = 1; i <= w; i++){
		std::cout << lines[i] << std::endl;
	}

	//while (1);
	return 0;
}