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

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

int parse(string a){
int s=0;
for(char b:a){
	s*=10;
	s+=b-48;
}
return s;
}
vector<int>split(string a){
	vector<int>b;
	string c="";
	for(char d:a){
		if(d==','){b.push_back(parse(c));c="";}
		else c+=d;
	}
	b.push_back(parse(c));
	return b;
}
int main(){
	int a[30];
	int b,c;
	scanf("%d%d",&b,&c);
	for(int d=0;d<b;d++){
		a[d]=d;
	}
	for(int e=0;e<c;e++){
		string f;
		cin>>f;
		vector<int>g=split(f);
		int h=a[g[0]-1];
		a[g[0]-1]=a[g[1]-1];
		a[g[1]-1]=h;
	}
	for(int x=0;x<b;x++){
		printf("%d\n",a[x]+1);
	}
}

C++: #include <iostream>

using namespace std;

int main(){
	int w, n;
	cin >> w >> n;
	int s[w];

	for(int i=0; i<w; i++){
		s[i] = i+1;
	}
		while(n--){
		int a, b, c;
		cin >> a >> b;

		int tmp = s[a-1];
		s[a-1] = s[b-1];
		s[b-1] = tmp;
	}

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

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

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)

int main(){
    int w, n;
    cin >> w >> n;
    vector<int> num(w, 0);
    int it = 1;
    for(int& k : num) k = it++;
    rep(i, n){
        string a;
        cin >> a;
        int p = a[0] - '1', q = a[2] - '1';
        swap(num[p], num[q]);
    }
    for(int k : num)
      cout << k << endl;
    return 0;
}

C++: #include <iostream>
using namespace std;
int main (){
	int w,N,d[30],c[30];
	cin>>w>>N;
	for(int j=0;j<w;j++){
		d[j]=j+1;
		c[j]=d[j];
	}
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		d[a]=d[b];
		d[b]=c[a];
		c[a]=d[a];
	}
	for(int k=0;k<w;k++){
	cout<<d[k]<<endl;
	}

	return 0;
}