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 <stdio.h>
#include <stdlib.h>

int main(){
  int w,n,tmp,a,b;
  int i;
  int *arr;
  scanf("%d",&w);
  scanf("%d",&n);
  arr = (int *)calloc(w+1,sizeof(int));
  for(i=0;i<=w;i++)arr[i] = i;
  while(n){
    scanf("%d",&a);getchar();scanf("%d",&b);
    tmp = arr[a];
    arr[a] = arr[b];
    arr[b] = tmp;
    n--;
  }
  for(i=1;i<=w;i++)printf("%d\n",arr[i]);
}

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

int main(){
	int w, n;
	cin >> w;
	vector<int> num(31);
	for (int i = 1; i <= w; ++i) {
		num[i] = i;
	}
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a, b;
		char split;
		cin >> a >> split >> b;
		int temp;
		temp = num[a];
		num[a] = num[b];
		num[b] = temp;
	}
	for (int i = 1; i <= w; ++i) {
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> a(n);
  iota(begin(a), end(a), 0);
  for (int i = 0; i < m; ++i) {
    int x, y;
    char _;
    cin >> x >> _ >> y, --x, --y;
    swap(a[x], a[y]);
  }
  for (int i = 0; i < n; ++i) {
    cout << a[i] + 1 << '\n';
  }
}

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

int main()
{
    int num,buddy,*line,a,b,c;
    cin >> num >> buddy;
    line = new int[num];
    for(int i = 0 ; i < num ; i++){
        line[i] = i + 1;
    }
    for(int i = 0 ; i < buddy ; i++){
        scanf("%d,%d",&a,&b);
        c = line[a - 1];
        line[a - 1] = line[b - 1];
        line[b - 1] = c;
    }
    for(int i = 0 ; i < num ; i++){
        cout << line[i] << '\n';
    }

    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <stdio.h>
using namespace std;
int main(){
	int w,n;
	int a,b,c;
	cin>>w;
	cin>>n;
	int num[30] = {0};
	for(int i=-0;i<w;i++){
		num[i] = i+1;
	}
	for(int j=0;j<n;j++){
		scanf_s("%d,%d",&a,&b);
		c = num[a-1];
		num[a-1] = num[b-1];
		num[b-1] = c;
	}
	for(int k=0;k<w;k++){
		printf("%d\n",num[k]);
	}

	return 0;
}

C++:  /*
Let's play Amidakuji.

In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
	
						[picture]
	
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.

Your task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., w are assigne to the vertical lines from left to right.
 */
 
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

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

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
    int w,n,x,y;
    scanf("%d",&w);
    vector<int> l(w+1);
    for(int i=0;i<w+1;i++){
        l[i]=i;
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d,%d",&x,&y);
        swap(l[x],l[y]);
    }
    for(int i=1;i<w+1;i++){
        printf("%d\n",l[i]);
    }
    return 0;
}

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

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

C++: #include <iostream>
#include <vector>
#include <numeric>
#include <map>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int w, n; cin >> w >> n;
	vector<int> A(w);
	iota(A.begin(), A.end(), 1);
	for (int i = 0; i < n; i++) { int a, b; char c; cin >> a >> c >> b; swap(A[a - 1], A[b - 1]); }
	for (int i = 0; i < w; i++) cout << A[i] << endl;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define SQR(X) ((X)*(X))


int test = 0;
/* ここからが本編 */
int main(void)
{
  int i,j,k,l;
  int n;
  int w;
  int e[50];
  cin >> w;
  cin >> n;
  rep(i,w+1) {
    e[i] = i;
  }
  rep(i,n) {
    int a,b;
    char c;
    cin >> a >> c >> b;
    swap(e[a],e[b]);
  }
  REP(i,1,w+1) {
    cout << e[i] << endl;
  }
  return 0;
}

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

typedef struct{
    int l;
    int r;
}tint;
int main(){
    vector<tint> lines;
    tint ins;
    int w,n;
    int*ans = new int(w);
    cin >> w >> n;
    for(int i=0;i<n;i++){
        scanf("%d,%d",&ins.l,&ins.r);
        lines.push_back(ins);
    }
    for(int i=1;i<=w;i++){
        int a=i;
        for(int j=0;j<n;j++){
            if(lines[j].l==a){
                a=lines[j].r;
            }else if(lines[j].r==a){
                a=lines[j].l;
            }
        }
        ans[a-1]=i;
    }
    for(int i=1;i<=w;i++){
        cout << ans[i-1] << endl;
    }
    delete ans;
}

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

int main() {
	int w, n, a, b;
	char comma;
	int amida[31];
	for (int i = 1;i < 31;i++) amida[i] = i;
	cin >> w >> n;

	for (int i = 0;i < n;i++) {
		cin >> a >> comma >> b;
		swap(amida[a], amida[b]);
	}

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

	return 0;
}

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

using namespace std;

int main(){

	int w,n;
	cin >> w >> n;
	int line [w];

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

	char cmd[4];
	for(int i = 0; i < n; ++i){
		cin >> cmd;
		swap(line[cmd[0]-'0'-1], line[cmd[2]-'0'-1]);
	}

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

	return 0;
}