Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

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;
	}
}

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

int main() {
    int i, w, n;
    int a, b;
    int ami[40];

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

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

int main(void){
	int w, n;
	int val[31];
	cin >> w >> n;
	for(int i=0; i<=w; i++) val[i]=i;
	for(int i=0; i<n; i++){
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap(val[a],val[b]);
	}
	for(int i=1; i<=w; i++)
		cout << val[i] << endl;
	return 0;

}

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

int main() {
    int w, n;
    cin >> w >> n;
    vector<int> v(w);
    for(int i=0; i<w; ++i) {
        v[i] = i+1;
    }
    for(int i=0; i<n; ++i) {
        int a, b;
        scanf("%d,%d", &a, &b);
        a--; b--;
        swap(v[a], v[b]);
    }
    for(auto x : v) {
        cout << x << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main()
{
	int w,n,a,b,c;
	char null;
	cin>>w>>n;
	int l[w];
	for(int k=0;k<w;k++)
	{
		l[k]=k+1;
	}
	for(int i=0;i<n;i++)
	{
	cin>>a>>null>>b;
	c=l[a-1];
	l[a-1]=l[b-1];
	l[b-1]=c;
    }
    for(int j=0;j<w;j++)
    {
    cout<<l[j]<<endl;
	}
return 0;
}

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

using namespace std;

int w, n;

struct bar {
	int a, b;
};

vector <bar> v;
int order[35];

int main() {
	scanf("%d", &w);
	scanf("%d", &n);
	
	for (int i=0; i<n; i++) {
		bar r;
		scanf("%d, %d", &r.a, &r.b);
		v.push_back(r);
	}
	
	for (int i=1; i<=w; i++) {
		int s = i;
		for (int j=0; j<n; j++) {
			if (v[j].a==s) s = v[j].b;
			else if (v[j].b==s) s = v[j].a;
		}
		order[s] = i;
	}
	
	for (int i=1; i<=w; i++) cout << order[i] << endl;
	
	return 0;
}

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

using namespace std;

int main() {
    int w, n, h[31][2], v[31], pos;
    cin >> w >> n;

    for (int i = 0; i < n; i++) {
        scanf("%d, %d", &h[i][0], &h[i][1]);
    }
    for (int i = 1; i <= w; i++) {
        pos = i;
        for (int j = 0; j < n; j++) {
            if (pos == h[j][0]) {
                pos = h[j][1];
            }
            else if (pos == h[j][1]) {
                pos = h[j][0];
            }
        }
        v[pos] = i;
    }
    for (int i = 1; i <= w; i++) {
        cout << v[i] << endl;
    }
    
    return 0;
}