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 <string>
using namespace std;

int main() {
	int w, n, x, y;
	string str;
	cin >> w >> n;
	int a[31];
	for (int i = 0; i <= w; i++) {
		a[i] = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> str;
		x = str[0];
		y = str[2];
		cout << x << y << endl;
		int tmp = a[x-48];
		a[x-48] = a[y-48];
		a[y-48] = tmp;
	}
	for (int i = 1; i <= w; i++) {
		cout << a[i] << endl;
	}
	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);
		int right = stoi(r);
		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 "bits/stdc++.h"
using namespace std;

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

	for(int i=0;i<n;i++){
		int a,b;
		(cin>>a).ignore()>>b;
		a--;
		b--;
		int tmp=x[a];
		x[a]=x[b];
		x[b]=tmp;
	}
	for(int i=0;i<w;i++)cout<<x[i]<<endl;
	return 0;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

void
swap(int* v, int i, int j) {
  int t = v[i];
  v[i] = v[j];
  v[j] = t;
}

int main() {

  int w, n; cin >> w >> n;
  int xs[w];
  rep (i, w) xs[i] = (i+1);
  rep (i, n) {
    char comma;
    int a, b; cin >> a >> comma >> b;
    --a; --b;
    swap(xs, a , b);
  }
  rep (i, w) cout << xs[i] << endl;

  return 0;
}

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

int main(){
    int w;
    int n;

    int a1, a2;
    int tmp;


    cin >> w >> n;

    vector<int> a(w);

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

    for(int i=1; i<=n; i++){
        scanf("%d,%d", &a1, &a2);
        tmp = a[a1-1];
        a[a1-1] = a[a2-1];
        a[a2-1] = tmp;
    }

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

    return 0;
}

C++: #include<iostream>
//#include"Header.h"
using namespace std;
#define size_n 4
#define size_num 30

template<typename T> void show_array(T ar,int ar_size)
{
	for(int i=0;i<ar_size;i++){
		cout << '[' << i << "]=" << ar[i] << ',';
	}
	cout << "\b " << endl;
}

int main(){
	int swap_times;
	int num_length;
	char n[size_n]={'\0'};
	int num[size_num] = {0};
	int temp;
	cin >> num_length;
	cin >> swap_times;

	for(int i=1;i <= num_length;i++){
		num[i] = i;
	}

	for(int i=1;i<=swap_times;i++){
		cin >> n;
		temp					= num[(int)n[0]-(int)'0'];
		num[(int)n[0]-(int)'0'] = num[(int)n[2]-(int)'0'];
		num[(int)n[2]-(int)'0'] = temp;

		//データの初期化
		for(int i=0;i<size_n;i++){
			n[i] = '\0';
		}
	}

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

	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main() {
	int array[30];
	int w, n;

	cin >> w;
	cin >> n;
	for(int i = 0; i < w; i++) {
		array[i] = i + 1;
	}
	for(int i = 0; i < n; i++) {
		int a, b, c;
		scanf("%d,%d", &a, &b);
		c = array[a - 1];
		array[a - 1] = array[b - 1];
		array[b - 1] = c;
	}

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

	return 0;
}

C++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(ll a=0;a<t;a++)
int main()
{
	ll w, n;

	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	ll a[32];
	roop(i, 32) {
		a[i] = i + 1;
	}
	roop(i, n) {
		string s;
		cin >> s;
		string d[2];
		roop(i, s.length()) {
			if (s[i] == ',') { d[0] = s.substr(0, i); d[i] = s.substr(i + 1); break; }
		}
		ll swap[2];
		roop(i, 2) {
			swap[i] = stoi(d[i]);
		}
		ll before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	roop(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

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

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

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

C++: #include <iostream>

int main(){
	int a,b,c,g,h;
	std::cin>>a>>b;
    int d[a];
    for(int e=1;e<=a;e++){
    	d[e]=e;
    	
	}
	for(int f=0;f<b;f++){
		std::cin>>g>>h;
		c=d[g];
		d[g]=d[h];
		d[h]=c;
	}
	for(int i=1;i<=a;i++){
		std::cout<<d[i]<<std::endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n, m, lot[30];
	scanf("%d %d",&n,&m);
	for(int i=0; i<n; i++){lot[i] = i+1;}
	while(m--){
		int a, b;
		scanf("%d,%d",&a,&b);
		swap(lot[a-1],lot[b-1]);
	}
	for(int i=0; i<n; i++){printf("%d\n",lot[i]);}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define M 10000000
#define bag cout<<"here\n"
using namespace std;
int main()
{
    long int v,h,a,b,c;
    while(cin>>v)
    {
        int arr[v];
        for(int i=0;i<v;i++)
          arr[i]=i+1;
        cin>>h;
        for(int i=1;i<=h;i++)
        {
           scanf("%d %*c %d",&a,&b);
           swap(arr[a-1],arr[b-1]);
        }
        for(int i=0;i<v;i++)
          cout<<arr[i]<<endl;
    }
    return 0;
}