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

int main(){
int a,b,c[60],d[30];
cin >> a;cin >> b;
for(int i = 0;i <= (b - 1);i++){
	scanf("%d,%d",&c[2 * i],&c[2 * i + 1]);
}
for(int e = 1;e <= a;e++){
	d[e - 1] = e;
}
for(int f = 0;f <= b - 1;f++){
	swap(d[c[2 * f] - 1],d[c[2 * f + 1] - 1]);
}
for(int g = 0;g <= a - 1;g++){
	cout << d[g] << endl;
}
fflush(stdin);
getchar();


return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(){
    int w, n;
    int d[31];
    while(cin >> w >> n){
        for(int i=1;i<=w;i++) d[i] = i;
        for(int i=0;i<n;i++){
            string s; cin >> s;
            for(int j=0;j<s.size();j++)
                if(s[j]==',') s[j] = ' ';
            istringstream iss(s);
            int a, b; iss >> a >> b;
            swap(d[a], d[b]);
        }
        for(int i=1;i<=w;i++) cout << d[i] << endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int w,n;
	int a,b;

	cin >> w >> n;

	int h[w];

	for(int i = 0;i < w;i++){
		h[i] = i+1;
	}
	for(int i = 0;i < n;i++){
		scanf("%d,%d",&a,&b);
		swap(h[a-1],h[b-1]);
	}

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define INF 2000000000



using namespace std;
int main(void){
    int n,m;
    vector<int> v;
    cin>>n>>m;
    rep(i,0,n){
        v.push_back(i+1);
    }
    
    rep(i,0,m){
        int x,y;
        char c;
        cin>>x>>c>>y;
        x--; y--;
        int swap;
        swap=v[x];
        v[x]=v[y];
        v[y]=swap;
        
    }
    
    rep(i,0,n) cout<<v[i]<<endl;
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <vector>

using namespace std;

void exchange(vector<int> &array, int w, vector<vector <int> > n){

  for(int i=0;i<n.size();i++){
    int a = n[i][0]-1;
    int b = n[i][1]-1;
    //    cout << "a: " << a << ", b: " << b << endl;
    int tmp = array[a];
    array[a] = array[b];
    array[b] = tmp;
  }  
}
  

int main(){

  int w, n;
  cin >> w;
  cin >> n;

  vector<vector <int> > Yoko;
  Yoko.resize(n);
  
  for(int i=0;i<n;i++){
    Yoko[i].resize(2);
    int a, b;
    char c;
    cin >> a >> c >> b;
    Yoko[i][0] = a;
    Yoko[i][1] = b;
  }

  vector<int> array;
  for(int i=0;i<w;i++){
    array.push_back(i+1);
  }
  
  exchange(array, w, Yoko);

  for(int i=0;i<array.size();i++){
    cout << array[i] << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int w, n, l, r;
    cin >> w >> n;

    vector<int>a(w+1);
    for(int i=0; i<w+1; i++) a[i] = i;

    for(int i=0; i<n; i++){
        scanf("%d,%d", &l,&r);
        swap(a[r], a[l]);
    }

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

    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;
int w;
int line[30][2];
int perm[31];

int main() {
	cin >> n;
	cin >> w;
	for (int i = 0; i < w; i++) {
		string str;
		cin >> str;
		line[i][0] = str[0] - '0';
		line[i][1] = str[2] - '0';
	}

	for (int i = 1; i <= n; i++) {
		int pt = i;
		for (int j = 0; j < w; j++) {
			if (line[j][0] == pt) pt = line[j][1];
			else if (line[j][1] == pt) pt = line[j][0];
		}
		perm[pt] = i;
	}

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

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

C++: #include<iostream>
#include<stdio.h>
#define N 30
using namespace std;
int main(){
  int w,n,tmp;
  int lod[N]; int lis[N][3];
  while(cin >> n >> w){
  for(int i = 0;i<n;i++){
    lod[i] = i+1;
  }
 
  for(int i=0;i<w;i++){
    scanf("%d,%d",&lis[i][0],&lis[i][2]);
  }
  for(int i=0;i<w;i++){
    tmp = lod[lis[i][0]-1];
    lod[lis[i][0]-1] = lod[lis[i][2]-1];
    lod[lis[i][2]-1] = tmp;
  }
  for(int i=0;i<n;i++){
    cout << lod[i] << endl;
  }
  }
}

C++: #include <iostream>
#include <utility>
using namespace System;
using namespace std;
const int MAX_W = 30;
int main()
{
    int w,n;
	int num[MAX_W+1]={};
	char c;
	cin>>w>>n;
	for(int i=0;i<w;i++){
		num[i]=i+1;
	}
	int a,b;
	for(int i=0;i<n;i++){
		cin>>a>>c>>b;
		swap(num[a-1],num[b-1]);
	}
	for(int i=0;i<w;i++){
		cout<<num[i]<<endl;
	}
    return 0;
}

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

using namespace std;

int swap(int nowAt, int a, int b) {
    if (a == nowAt) {
        return b;
    }
    if (b == nowAt) {
        return a;
    }

    return nowAt;
}

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main() {
    int w, n, i, ii, nowAt;

    cin >> w >> n;

    int results[w];

    // ルートの読み込み
    int routes[n][2];
    for (i = 0; i < n; i++) {
        string buffer;
        cin >> buffer;

        vector<string> splitted = split(buffer, ',');
        routes[i][0] = stoi(splitted[0]);
        routes[i][1] = stoi(splitted[1]);
        vector<string>().swap(splitted); // メモリの解放
    }

    // それぞれあみだくじをやる
    for (i = 0; i < w; i++) {
        nowAt = i+1; // 最初の位置

        // あみだの全節を通る
        for (ii = 0; ii < n; ii++) {
            nowAt = swap(nowAt, routes[ii][0], routes[ii][1]);
        }

        results[nowAt-1] = i + 1;
    }

    for(int goal : results) cout << goal << endl;
}