Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

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

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