Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func swap(ints []int, i, j int) {
	ints[i], ints[j] = ints[j], ints[i]
}

func main() {
	w := nextInt()
	// println(w)
	nums := make([]int, w)
	for i := range nums {
		nums[i] = i+1
	}
	n := nextInt()
	// println(n)
	for i := 0; i < n; i++ {
		info := nextString()
		// println(info)
		infos := strings.Split(info, ",")
		a, _ := strconv.Atoi(infos[0])
		b, _ := strconv.Atoi(infos[1])
		swap(nums, a-1, b-1)
	}
	for _, v := range nums {
		fmt.Println(v)
	}
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int w,n;
  scanf("%d %d",&w,&n);
  int left[n];
  int right[n];
  int ans[w+1];
  for(int i=0;i<n;i++) {
    scanf("%d,%d",&left[i],&right[i]);
  }
  for(int i=1;i<=w;i++) {
    int state = i;
    int t = 0;
    while(t<n) {
      if(left[t] == state) {
        state = right[t];
      }
      else if(right[t] == state) {
        state = left[t];
      }
      t++;
    }
    ans[state] = i;
  }
  for(int i=1;i<=w;i++) {
    printf("%d\n",ans[i]);
  }
}

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

int main() {
  int w, n, nx, ny;

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

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

using namespace std;
void lots(int len,int a,int b,int array[]){
    int buffer[5];
    for(int i = 0;i < len; i++){
        if(i == a-1){
            buffer[i] = array[b-1];
        }
        else if(i == b-1){
            buffer[i] = array[a-1];
        }
        else{
            buffer[i] = array[i];
        }
    }
    for(int i = 0; i < len; i++){
        array[i] = buffer[i];
    }

}

int main(){
    int len,duration,a,b;
    cin >> len;
    cin >> duration;
    int array[len];
    for(int i = 0; i < len; i++){
        array[i] = i+1;
    }
    for(int i = 0; i < duration; i++){
        scanf("%d,%d",&a,&b);
        lots(len,a,b,array);
    }
    for(int i = 0; i < len; i++){
        cout << array[i] << endl;
    }
}

C++: #include <stdio.h>

int
main(void)
{
	char line[80];
	int w;
	int n;

	if (fgets(line, sizeof line, stdin) == NULL) {
		return 1;
	}
	if (sscanf(line, "%d", &w) != 1) {
		return 1;
	}

	if (fgets(line, sizeof line, stdin) == NULL) {
		return 1;
	}
	if (sscanf(line, "%d", &n) != 1) {
		return 1;
	}

	int a[n];
	int b[n];

	for (int i = 0; i < n; i++) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			return 1;
		}
		if (sscanf(line, "%d,%d", &(a[i]), &(b[i])) != 2) {
			return 1;
		}
	}

	int r[w];
	for (int i = 1; i <= w; i++) {
		int k = i;
		for (int j = 0; j < n; j++) {
			if (a[j] == k) {
				k = b[j];
			} else if (b[j] == k) {
				k = a[j];
			}
		}
		r[k-1] = i;
	}

	for (int i = 0; i < w; i++) {
		printf("%d\n", r[i]);
	}

	return 0;
}

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

int main(){
  int w, n, wd[31];
  for(int i = 0; i < 31; i++) wd[i] = i+1;
  cin >> w;
  cin >> n;
  for(int i = 0; i < n; i++){
    int a, b, tmp;
    scanf("%d,%d", &a, &b);
    tmp = wd[a-1];
    wd[a-1] = wd[b-1];
    wd[b-1] = tmp;
  }

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

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int w;
	cin >> w;

	vector<int> a;
	for (int i = 0; i < w; i++)
	{
		a.push_back(i + 1);
	}

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int x, y;

		string s;
		cin >> s;

		stringstream ss;
		ss << s;

		ss >> x;
		ss.ignore();
		ss >> y;

		swap(a.at(x - 1), a.at(y - 1));
	}

	for (int i = 0; i < w; i++)
	{
		cout << a.at(i) << endl;
	}
}

C++: #include <cstdio>
#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>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){

  int n,m,x,y;

  vector <int> a;

  cin >> n;

  for(int i=0;i<=n;i++){
    a.push_back(i);
    a[i]=i;
  }

  cin >> m;
  for(int i=0;i<m;i++){
    scanf("%d,%d",&x,&y);
    swap(a[x],a[y]);
  }

  for(int i=1;i<=n;i++) cout << a[i] << endl;
}