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






}

C++: #include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;


std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);
 
    std::vector<std::string> result;
 
    while (first < str.size()) {
        std::string subStr(str, first, last - first);
 
        result.push_back(subStr);
 
        first = last + 1;
        last = str.find_first_of(del, first);
 
        if (last == std::string::npos) {
            last = str.size();
        }
    }
 
    return result;
}

int main(){
    int w,n;
    cin >> w >> n;
    vector<int> N(w);
    for(int i=0; i<w; i++) N[i]=i;
    // rep(i,w) cout << N[i]; cout << endl;
    // cout << endl;
    rep(i,n){
        string s;
        cin >> s;
        vector<string> A = split(s, ',');
        string a = A[0], b = A[1];
        // cout << a << " " <<b << endl;
        int tmp=N[stoi(a)-1];
        N[stoi(a)-1]=N[stoi(b)-1];
        N[stoi(b)-1]=tmp;

    }
    rep(i,w) cout << N[i]+1 << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define EPS 1.0e-8
#define MAX_N 100
typedef pair<int,int> Pii;
typedef pair<int,int> Pis;
const double PI=acos(-1);

int main(){
	int w, n;
	int stage[30];
	int a, b;
	cin >> w >> n;
	rep(i,w) stage[i] = i+1;

	rep(i,n){
		scanf("%d,%d",&a,&b);	
		stage[a-1] ^= stage[b-1];
		stage[b-1] ^= stage[a-1];
		stage[a-1] ^= stage[b-1];
	}

	rep(i,w)	cout << stage[i] << endl;
}

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

int now[30];

int main()
{
	int w,n;
	scanf("%d%d",&w,&n);
	for(int i = 0; i < w; i++)
	{
		now[i] = i + 1;
	}
	for(int i = 0; i < n; i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		int w = now[a - 1];
		now[a - 1] = now[b - 1];
		now[b - 1] = w;
	}
	for(int i = 0; i < w; i++)
	{
		printf("%d\n",now[i]);
	}
	return 0;
}