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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int w, n, a, b;

	cin >> w >> n;
	vector<int> hlines(w);
	for (int i = 0; i < w; ++i) {
		hlines.at(i) = i + 1;
	}

	for (int i = 0; i < n; ++i) {
		cin >> a;
		cin.ignore();
		cin >> b;
		--a, --b;
		swap(hlines.at(a), hlines.at(b));
	}
	for (int i = 0; i < w; ++i) {
		cout << hlines.at(i) << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int w, n;
    char comma;
    int ab[31][2];
    int ans[31];
    
    cin >> w >> n;
    for (int i = 0; i < n; i++)
        cin >> ab[i][0] >> comma >> ab[i][1];

    for (int i = 1; i <= w; i++) {
        int state = i;
        int pos = 0;
        for (int j = 0; j < n; j++) {
            if (pos == 0) {
                if (ab[j][0] == state) {
                    state = ab[j][1];
                    pos = 1;
                }
                else if (ab[j][1] == state) {
                    state = ab[j][0];
                    pos = -1;
                }
            }
            else if (pos == -1 && ab[j][0] == state) {
                state = ab[j][1];
                pos = 1;
            }
            else if (pos == 1 && ab[j][1] == state) {
                state = ab[j][0];
                pos = -1;
            }
        }
        ans[state] = i;
    }

    for (int i = 1; i <= w; i++)
        cout << ans[i] << "\n";

    return 0;
}

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

int main() {
	int w, n, a, b;
	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 >> b;
		swap(amida[a], amida[b]);
	}

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

	return 0;
}

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

int main(int argc, const char * argv[])
{
    int w, n;
    std::cin >> w >> n;
    int a[w];
    for (int i = 0; i < w; i++) {
        a[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        int aa, bb, tmp;
        scanf("%d,%d", &aa, &bb);
        tmp = a[aa - 1];
        a[aa - 1] = a[bb - 1];
        a[bb - 1] = tmp;
    }
    for (int i = 0; i < w; i++) {
        printf("%d\n", a[i]);
    }
    
    return 0;
}

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

int main()
{
	int w;cin>>w;
	int n;cin>>n;
	vector<int>P(w+1);
	for ( int i=0; i<=w; i++ )
		P[i]=i;
	for ( int i=0; i<n; i++ )
	{
		int a,b;
		char c;
		cin>>a>>c>>b;
		swap(P[a],P[b]);

	}
	for ( int i=1; i<=w; i++ )
		cout << P[i]<<endl;
	return 0;



}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	int w;
	int n;
	int number[30] = {0};
	int kari;
	int a, b;
	char c;

	cin >> w;
	cin >> n;

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

	for(int i = 0; i < n; i++) {
		cin >> a >> c >> b;
		kari = number[a-1];
		number[a-1] = number[b-1];
		number[b-1] = kari;
	}

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

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int* a;

void swap(int j, int k) {
    int temp = a[j];
    a[j] = a[k];
    a[k] = temp;
}

int main() {
    int w, n;
    cin >> w >> n;
    a = new int[w];
    REP(i,w) {
        a[i] = i+1;
    }
    REP(i,n) {
        int j, k;
        scanf("%d,%d", &j, &k);
        swap(j-1, k-1);
    }
    REP(i,w) {
        cout << a[i] << endl;
    }
    delete[] a;
    return 0;
}

C++: #include<iostream>
int main(){
	int w,n,a[30][2],b[30];
	std::cin>>w
		>>n;
	for(int i=0;i<n;++i){
		for(int j=0;j<2;++j){
			std::cin>>a[i][j];
		}
	}
	for(int i=1;i<=w;++i){
		b[i]=i;
	}
	for(int i=0;i<n;++i){
			int x=b[a[i][0]];
			b[a[i][0]]=b[a[i][1]];
			b[a[i][1]]=x;
	}
	for(int i=1;i<=w;++i){
		std::cout<<b[i]<<std::endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	int w, n;
	cin >> w;
	cin >> n;
	cin.ignore();
	
	vector<int> v(w);
	for(int i = 1; i <= v.size(); i++){
		v[i - 1] = i;
	}

	int a, b, c;
	string buf;
	for(int i = 0; i < n; i++){
		getline(cin, buf);
//		cin >> buf;
		sscanf(buf.c_str(), "%d, %d", &a, &b);
		c = v[a - 1];
		v[a - 1] = v[b - 1];
		v[b - 1] = c;
	}
	for(int& i : v){
		cout << i << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.ignore(1, '\n');
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_b) - 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>

const static int MAX = 31;

int main()
{

    int N, M, x, y;
    char c;
    std::scanf("%d", &N);
    int arr[N];
    for (int i = 1; i <= N; i++) arr[i] = i;
    std::scanf("%d", &M);
    for (int i = 0; i < M; i++) {
        std::scanf("%d%c%d", &x, &c, &y);
        std::swap(arr[x], arr[y]);
    }
    for (int i = 1; i <= N; i++) std::printf("%d\n", arr[i]);

    return 0;
}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
#include <sstream>

using namespace std;
typedef pair<int,int> P;
vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

int main(){
  int w,n;
  cin>>w;
  cin>>n;
  int ami[40];
  P bou[40];
  for(int i=0;i<n;i++){
    int x=0,y=0;
    scanf("%d,%d",&x,&y);
    bou[i]=P(x,y);
  }
  for (int i=0;i<w;i++){
    int start=i+1;
    for(int j=0;j<n;j++){
      if(bou[j].first==start){start=bou[j].second;}
      else if(bou[j].second==start){start=bou[j].first;}
    }
    ami[start]=i+1;
  }
  for(int i=1;i<=w;i++)cout<<ami[i]<<endl;






}