Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	lines, _ := strconv.Atoi(sc.Text())
	l := make([]int, lines)
	for i := 0; i < lines; i++ {
		l[i] = i + 1
	}

	sc.Scan()
	rows, _ := strconv.Atoi(sc.Text())
	for i := 0; i < rows; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), ",")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])

		l[a-1], l[b-1] = l[b-1], l[a-1]
	}
	for _, j := range l {
		fmt.Println(j)
	}
}

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


int main()
{
	int w, n, num[31];
	string s;
	cin >> w;
	fill(num, num + 31, 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 = atoi(l.c_str());
		int right = atoi(r.c_str());
		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;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int w, n, a, b, r[30];

int main() {
	scanf("%d %d",&w,&n);
	rep(i,w) r[i] = i+1;
	rep(i,n) {
		scanf("%d,%d",&a,&b);
		swap(r[a-1], r[b-1]);
	}
	rep(i,w) printf("%d\n",r[i]);
}

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

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

C++: #include <iostream>
#include <map>
#include <vector>
#define P pair<int, int>
using namespace std;

int main()
{	
	int w, n;
	cin >> w >> n;
	vector<int> v(w);
	for (int i = 1; i <= w; i++)
		v[i - 1] = i;
	P p;
	int t;
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &p.first, &p.second);
		t = v[p.first - 1];
		v[p.first - 1] = v[p.second - 1];
		v[p.second - 1] = t;
	}
	
	for (int i = 0; i < w; i++)
		cout << v[i] << endl;
	
		
	return 0;
}

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

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