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 <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;
	}														//1 = 49
	for (int i = 0; i < n; i++) {
		cin >> str;
		x = stoi(str);
		if (to_string(x).size()==1&&str.size()==3){
			int temp = str[2];
			y = temp-48;
		}
		else if(to_string(x).size()==2&&str.size()==4){
			int temp = str[3];
			y = temp - 48;
		}
		else if(to_string(x).size()==1&&str.size()==4){
			int juunokurai = str[2];
			int itinokurai = str[3];
			y = (juunokurai - 48) * 10 + (itinokurai - 48);
		}
		else {
			int juunokurai = str[3];
			int itinokurai = str[4];
			y = (juunokurai - 48) * 10 + (itinokurai - 48);
		}
		int tmp = a[x];
		a[x] = a[y];
		a[y] = tmp;
	}
	for (int i = 1; i <= w; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

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

int main() {
  int w,n,a1,b1,change;
  int num[40];
  string str;
  cin >> w;
  for(int i=1;i<w+1;i++) {
    num[i] = i;
  }
  cin >> n;
  for(int i=1;i<n+1;i++) {
    cin >> str;
    a1 = strtol(str.substr(0).c_str(),NULL,0);
    b1 = strtol(str.substr(2).c_str(),NULL,0);
    change = num[a1];
    num[a1] = num[b1];
    num[b1] = change;
  }
  for(int i=1;i<w+1;i++) {
    cout << num[i] << endl;
  }
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  int w, n, i;
  cin >> w >> n;
  int num[w + 1], a[n + 1], b[n + 1];

  REP(i, w) num[i] = i + 1;
  REP(i, n) scanf("%d,%d" ,&a[i], &b[i]);
  REP(i, n) swap(num[a[i] - 1], num[b[i] - 1]);
  REP(i, w) cout << num[i] << endl;
}

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>
#include<cstdio>
using namespace std;
#define F(I,J,N) for(int I=J;I<N;I++)

void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(){
	int *l;
	int p,q;
	int x,y;
	while(cin>>p){
		l=new int[p];
		F(i,0,p) l[i]=i+1;
		cin>>q;
		F(i,0,q){
			scanf("%d,%d",&x,&y);
			swap(&l[x-1],&l[y-1]);
		}
		F(i,0,p) cout<<l[i]<<endl;
		delete []l;
	}
}

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

int main(){
	int w,n;
	cin>>w>>n;
	int a[w+1];
	for(int i=1;i<=w;i++) a[i]=i;
	for(int i=0;i<n;i++){
		string x;
		cin>>x;
		int z=a[x[0]-'0'];
		a[x[0]-'0']=a[x[2]-'0'];
		a[x[2]-'0']=z;
	}
	for(int i=1;i<=w;i++) cout<<a[i]<<endl;
	return 0;
}

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


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

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.ignore(INT_MAX, '\n');
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_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;
int data[40];
int main(){

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

C++: #include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int w, n;
	int a[30], b[30];
	int now[30];
	int x, y;

	cin >> w;
	cin >> n;
	
	for (int i = 0; i < n; i++){
		scanf_s("%d,%d", &x, &y);
		a[i] = x;
		b[i] = y;
	}


	for (int j = 0; j < n; j++){
		for (int i = 0; i < w; i++){
			if (now[i] == a[j]){
				now[i] = b[j];
				now[b[j]] = a[j];
				break;
			}
		}
	}

	for (int i = 0; i < n; i++){
		printf("%d\n", now[i]);
	}

	return 0;
}

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

int main(){
	int w;
	int n;
	int a, b;

	cin >> w >> n;
	
	int number[30];
	for(int i = 0; i < w; i++){
		number[i] = i+1;
	}

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

	return(0);
}

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

int main()
{	int data[30],i,w,n,a,b,c;
	cin >> w >> n;
	for(i=0;i<w;i++){
		data[i]=i+1;
	}

	for(i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		c=data[a-1];
		data[a-1]=data[b-1];
		data[b-1]=c;
	}
	for(i=0;i<w;i++){
		printf("%d\n",data[i]);
	}
	return 0;
}

C++: // あみだくじ

#include <iostream>
using namespace std;

int amida[30][2];
void read_input(int n);
void run(int w, int n);

int main() {
    int w; // w: たて棒
    int n; // n: よこ棒

    cin >> w >> n;
    read_input(n);
    run(w, n);
    return 0;
}

void run(int w, int n) {
    // 現在位置がamida[idx]のどちらかと同じだったら移動
    int final_positions[30]; // 最後の位置を溜める

    for (int start = 0; start < w; start++) {
        int current_pos = start;
        for (int idx = 0; idx < n; idx++) {
            if (current_pos == amida[idx][0]) {
                current_pos = amida[idx][1];
            } else if (current_pos == amida[idx][1]) {
                current_pos = amida[idx][0];
            }
        }
        final_positions[current_pos] = start+1;
    }
    for (int i = 0; i < w; i++)
        cout << final_positions[i] << "\n";
}

void read_input(int n){
    // read input and assign them to amida
    for (int idx = 0; idx < n; idx++) {
        int tmp;
        cin >> tmp;
        amida[idx][0] = tmp - 1; // 0から始まるインデックス
        cin.ignore(); // カンマ
        cin >> tmp;
        amida[idx][1] = tmp - 1;
    }
}

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

using namespace std;

int main()
{
	int w, n;
	int a, b;
	int data[30][2];
	int data2[30][2];
	int temp;
	int i, j, k;
	int out[30];
	
	cin >> w >> n;
	
	for(i = 0; i < n; i++){
		scanf("%d,%d",&a,&b);
		data[i][0] = a;
		data[i][1] = b;		
	}
	
	for(i = 1; i < w+1; i++){
		
		//¡Ì}ÌÔ
		temp = i;
		
		for(j = 0; j < n; j++){
			if(data[j][0] == temp){
				temp = data[j][1];
			}
			else if(data[j][1] == temp){
				temp = data[j][0];
			}
		}
		
	//	printf("%dÍ%dÖ\n",i,temp);
		out[temp] = i;
	}
	
	for(int i = 1; i < w+1; i++){
		cout << out[i] << endl;
	}
}