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 <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	int W, N; scanf(" %d %d", &W, &N);
	vector<int> arr(W+1);
	rep(i,W+1) arr[i] = i;
	rep(i,N) {
		int a, b; scanf(" %d,%d", &a, &b);
		swap(arr[a], arr[b]);
	}
	rep(i,W) printf("%d\n", arr[i+1]);
	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	int w,n,t[30];
	scanf("%d%d",&w,&n);
	rep(i,w) t[i]=i;
	rep(i,n){
		string s;
		cin >> s;
		int a=0,b=0,cnt=0;
		for(;s[cnt]!=',';cnt++){
			a*=10;
			a+=(s[cnt]-'0');
		}
		for(cnt++;cnt<s.size();cnt++){
			b*=10;
			b+=(s[cnt]-'0');
		}
		swap(t[a-1],t[b-1]);
	}
	rep(i,w) printf("%d\n",t[i]+1);
	return 0;
}

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

using namespace std;

int main(){
	int VLineNum, HLineNum;
	cin >> VLineNum;
	cin >> HLineNum;

	int* Data = new int[VLineNum];//あみだくじNo.配列初期化
	for (int i = 0; i < VLineNum; ++i){
		Data[i] = i + 1;
	}

	int a, b, temp;//データロード&あみだくじ数値反転
	for (int i = 0; i < HLineNum; ++i){
		scanf("%d,%d", &a, &b);
		temp = Data[b-1];
		Data[b-1] = Data[a-1];
		Data[a-1] = temp;
	}

	for (int i = 0; i < VLineNum; ++i){//出力
		cout << Data[i] << endl;
	}

	delete [] Data;

	return 0;
}

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

int main()
{
  int w,n;
  int c[]={0};
  int a,b;
  //  int temp;

  scanf("%d",&w);
  scanf("%d",&n);

  for(int i=0; i<=n; i++){
    c[i]=i;
  }

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

  for(int i=1; i<=w; i++){
    printf("%d",c[i]);
  }
}

C++: #include<algorithm>
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int lot[33]; // くじ
  int w,n,a,b;
  for(int i=1;i<=30;i++)lot[i] = i;
  cin >> w >> n;

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

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

C++: #include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int ans[31]={};
int a[31],b[31];

int main() {

	int w,n;
	cin>>w;
	cin>>n;
	char c=',';
	rep(i,n)cin>>a[i]>>c>>b[i];
	for(int i=1; i<w+1; i++){
		int x=i;
		rep(j,n){
			if(x==a[j])x=b[j];
			else if(x==b[j])x=a[j];
		}
		ans[x]=i;
	}
	rep(i,w)cout<<ans[i+1]<<endl;

	return 0;
}

C++: #include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int w,n;
  int a[30],b[30],c[30];
  cin >> w >> n;
  for (int i = 0; i < w; i++) {
    c[i] = i+1;
  }
  char x;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> x >> b[i];
    // cout << a[i] << " " << b[i] << endl;
  }
  for (int i = 0; i < n; i++) {
    // swap(c[a[i]-1], c[b[i]-1]);
    int k = a[i] - 1;
    int j = b[i] - 1;
    int tmp = c[k];
    c[k] = c[j];
    c[j] = tmp;
  }
  for (int i = 0; i < w; i++) {
    cout << c[i] << endl;
  }
}

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


int main()
{
	int w, n, num[31];
	string s;
	cin >> w;
	fill(num, num + 31, 0);
	for (int i = 1; i < w + 1; i++){
		num[i] = i;
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		string l, r;
		int commapos;

		//カンマの左
		for (int i = 0;; i++){
			if (s[i] == ','){
				commapos = i;
				break;
			}
			else{
				l += s[i];
			}
		}

		//カンマの右
		for (int i = commapos + 1; i < s.length(); i++){
			r += s[i];
		}
		int left = atoi(l.c_str());
		int right = atoi(r.c_str());
		int temp = num[left];
		num[left] = num[right];
		num[right] = temp;
	}
	for (int i = 1; i < w + 1; i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <cstdio>
#define SWAP(a,b) {a+=b,b=a-b,a-=b;}

using namespace std;

int W[30];

int main()
{
	int w,n,ai,bi;
	scanf("%d",&w);
	for(int i=0;i<w;++i) W[i]=i+1;
	scanf("%d",&n);
	for(int i=0;i<n;++i) {
		scanf("%d,%d",&ai,&bi);
		SWAP(W[ai-1],W[bi-1]);
	}
	for(int i=0;i<w;++i) { printf("%d\n",W[i]); }
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

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

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

using namespace std;

void Swap(vector<int>& v, int index1, int index2) {
    int tmp = v[index1];
    v[index1] = v[index2];
    v[index2] = tmp;
}


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

    vector<int> v(w);
    for(int i = 0; i < v.size(); ++i) {
        v[i] = i + 1;
    }
    
    int n;
    cin >> n;

    for(int i = 0, a, b; i < n; ++i) {
        cin >> a;
        cin.ignore();
        cin >> b;

        Swap(v, a - 1, b - 1);
    }

    for(auto x : v) {
        cout << x << '\n';
    }

    return 0;
}

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

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int w, n;
	scanf("%d%d", &w, &n);

	vi line(w);
	rep(i, w) line[i] = i+1;
	rep(i, n){
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(line[a-1], line[b-1]);
	}

	rep(i, w) printf("%d\n", line[i]);

	return 0;
}