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++: //
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int w = 0;
    cin >> w;
    
    int n = 0;
    cin >> n;
    
    int c[w];
    for(int i = 0; i < w; i++){
        c[i] = i + 1;
    }
    
    int a, b;
    int buffer;
    for (int i = 0; i < n; i++) {
        if(scanf("%d,%d",&a, &b) != EOF){;
            //printf("a: %d, b: %d ;; ", a, b);
            //printf("%d, %d -> ", c[a - 1], c[b - 1]);
            buffer = c[a - 1];
            c[a - 1] = c[b - 1];
            c[b - 1] = buffer;
            //printf("%d, %d\n", c[a - 1], c[b - 1]);
        }
    }
    for (int i = 0; i < w; i++) {
        printf("%d\n", c[i]);
    }
    
    
    return 0;
}

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


int main()
{
	int w, n, num[32];
	string s;
	cin >> w;
	fill(num, num + 32, 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 < (signed)s.length(); i++){
			r += s[i];
		}
		int left = stoi(l.c_str());
		int right = stoi(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 <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

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

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;
  
int main() {
int w,n; cin >> w >> n;
int a[31];
rep(i,0,w) a[i] = i+1;
  
rep(i,0,n) {
int x,y;
scanf("%d,%d",&x,&y);
swap(a[x-1],a[y-1]);
}
rep(i,0,n) cout << a[i] << endl;
return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int h,v,i,l,r;
int a[30];
for (i=0;i<30;i++) a[i]=i;
cin >> h >> v;
for (i=0;i<v;i++) {
	cin >> l >> r ;
	swap(a[l],a[r]);
}
for (i=1;i<=h;i++) cout << a[i] << endl;
return 0;
}

C++: #include <cstdio>
#include <utility>
#include <vector>

int main() {
    std::vector<int> v;
    
    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
        v.push_back(i);
    }
    
    int n;
    scanf("%d", &n);
    
    int a, b;
    while (~scanf("%d,%d", &a, &b)) {
        std::swap(v[a - 1], v[b - 1]);
    };
    
    for (const auto& i : v) {
        printf("%d\n", i + 1);
    }
}

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

int main(){
	int w,n;
	cin>>w>>n;
	int c[31];
	int a,b;
	for(int x=1;x<=w;x++){
		c[x]=x;
	}
	for(int y=0;y<n;y++){
		scanf("%d,%d",&a,&b);
		swap(c[a],c[b]);
	}
	for(int z=1;z<=w;z++){
		cout<<c[z]<<endl;
	}
	return 0;
	}

C++: #include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxw=30+5;
int w,n,rank[maxw];
int main(){
    scanf("%d%d",&w,&n);
    for(int i=1;i<=w;i++)
        rank[i]=i;
    for(int i=1,x,y;i<=n;i++){
        scanf("%d,%d",&x,&y);
        swap(rank[x],rank[y]);
    }
    for(int i=1;i<=w;i++)
        cout<<rank[i]<<endl;
    return 0;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	int a[n];
	for(int i = 0; i < n; i++){
		a[i] = i+1;
	}
	for(int i = 0; i < m; i++){
		stringstream ss1, ss2;
		string str;
		int p, q;
		cin >> str;
		ss1 << str[0];
		ss2 << str[2];
		ss1 >> p;
		ss2 >> q;
		swap(a[p-1],a[q-1]);
		
	}
	for(int i = 0; i < n; i++){
		cout << a[i] << endl;
	}
}

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

int main() {
	int w, n;
	string str;
	cin >> w >> n;
	int ami[30];
	for (int i = 0; i < w; i++) {
		ami[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		int a, b, temp;
		string str;
		cin >> a >> b;
		temp = ami[a-1];
		ami[a-1] = ami[b-1];
		ami[b-1] = temp;
	}
	for (int i = 0; i < w; i++) {
	cout << ami[i] <<endl;
	}

	return 0;
}

C++: #include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

int num[31];

int main(){
    rep(i,31)num[i]=i;
    int x,y;
    cin>>x>>y;
    
    int n,m;
    char b;
    rep(i,y){
        cin>>n>>b>>m;
        swap(num[n],num[m]);
    }
    for(int i=1;i<x+1;i++){
        cout<<num[i]<<endl;
    }
    return 0;
}

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

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

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int w, n, ans[31];
	cin >> w >> n;
	for (int i = 0; i <= 30; i++)
		ans[i] = i;
	for (int i = 0; i < n; i++) {
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap(ans[a], ans[b]);
	}
	for (int i = 1; i <= 30; i++)
		cout << ans[i] << endl;
}

C++: #include <iostream>
using namespace std;
void change(int num[],int a, int b)
{
	int tmp = num[a];
	num[a] = num[b];
	num[b] = tmp;
}
int main()
{
	int w,n;
	int order[30]={0};
	cin >> w >> n;
	for(int i=0; i < w; i++){
		order[i] = i;
	}
	while(n--){
		int a,b;
		scanf("%d , %d ", &a, &b);
		change(order, a-1, b-1);
	}
	for(int i=0; i< w; i++){
		cout << order[i]+1 << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstring>

using namespace std;

int main(){
    int w, n;
    int d[31];
    while(cin >> w >> n){
        for(int i=1;i<=w;i++) d[i] = i;
        for(int i=0;i<n;i++){
            string s; cin >> s;
            istringstream iss >> s;
            for(int j=0;j<s.size();j++)
                if(s[j]==',') s[j] = ' ';
            int a, b; iss >> a >> b;
            swap(d[a], d[b]);
        }
        for(int i=1;i<=w;i++) cout << d[i] << endl;
    }
}

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

vector<int> ans(31);

void swap(int a, int b){
  int tmp = ans[a];
  ans[a] = ans[b];
  ans[b] = tmp;
}

int main(){
  int w, n;

  cin >> w >> n;
  for(int i=1; i<=w; i++) ans[i] = i;

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

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