Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

C++: #include<iostream>

using namespace std;
int data[40];
int main(){

	for(int i=0;i<40;i++)data[i]=i;
	int w;
	int n;
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		char tmp[3];
		cin>>tmp;
		int a=tmp[0]-'0';
		int b=tmp[2]-'0';
		for(int i=1;i<=w;i++){
			if(data[i]==a){
				data[i]=b;
			}
			else if(data[i]==b){
				data[i]=a;
			}
		}
	}
	for(int i=1;i<=w;i++){
		int mi=40;
		int ans;
		for(int j=1;j<=w;j++){
			if(data[j]<mi){
				mi=data[j];
				ans=j;
			}
		}
		cout<<ans<<endl;
		data[ans]=40;
	}
}

C++: #include<stdio.h>

int main(){
int tate,yoko,bou[30][2],j,x,kekka[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30},i=0;
scanf("%d %d",&tate,&yoko);
for(j=0;j<yoko;j++){
scanf("%d,%d",&bou[j][1],&bou[j][2]);
}
for(i=1;i<tate+1;i++){
x=i;
for(j=0;j<yoko;j++){
if(bou[j][1]==x){
x=bou[j][2];
}
else if(bou[j][2]==x){
x=bou[j][1];
}
}
kekka[x-1]=i;
}
for(j=0;j<tate;j++){
printf("%d\n",kekka[j]);
}
}

C++: #include<iostream>
using namespace std;
int main(){
	int w, n, a[100] = { 0 },b,d,A=0;
	char c;
	cin >> w, n;
	for (int i = 1; i <= w; i++){
		a[i] = i;
	}
	for (int i = 1; i <= n; i++){
		A = 0;
		cin >> b, c, d;
		A = a[b];
		a[b] = a[c];
		a[c] = A;
	}
	for (int i = 1; i <= w; i++){
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
	int W[31], w, n, a, b;
	int i, j, temp;
	char x;

	cin >> w >> n;
	for(i = 1;i < w+1;i++){
		W[i] = i;
	}
	while(n != 0){
		if(n == 0) break;
		cin >> a >> x >>  b;
		temp = W[a];
		W[a] = W[b];
		W[b] = temp;
 		n--;
	}
	for(i = 1;i < w+1;i++){
		cout << W[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main() {
  int w,n,a1,b1,change;
  int num[30];
  string str;
  cin >> w;
  for(int i=1;i<w+1;i++) {
    num[i] = i;
  }
  cin >> n;
  for(int i=1;i<n+1;i++) {
    cin >> str;
    a1 = strtol(str.substr(0).c_str(),NULL,0);
    b1 = strtol(str.substr(2).c_str(),NULL,0);
    change = num[a1];
    num[a1] = num[b1];
    num[b1] = change;
  }
  for(int i=1;i<w+1;i++) {
    cout << num[i] << endl;
  }
}

C++: #include<iostream>
using namespace std;
int main(){
	int w, n = 0, a[100] = { 0 }, b, d, A = 0;
	char c = 0;
	cin >> w, n;
	for (int i = 1; i <= w; i++){
		a[i] = i;
	}
	for (int j = 1; j <= n; j++){
		cin >> b;
		cin >> c;
		cin >> d;
		A = a[b];
		a[b] = a[d];
		a[d] = A;
	}
	for (int k = 1; k <= w; k++){
		cout << a[k] << endl;
	}
	return 0;
}

C++: ///
// File:  0011.cpp
// Author: ymiyamoto
//
// Created on Thu Nov  9 00:53:28 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  uint32_t w, n;
  cin >> w;
  cin >> n;

  vector<uint32_t> lines;
  for (uint32_t i = 1; i <= w; i++) {
    lines.push_back(i);
  }

  for (uint32_t i = 0; i < n; i++) {
    uint32_t a, b;
    char sep;
    cin >> a >> sep >> b;
    swap(lines[a - 1], lines[b - 1]);
  }

  for (auto iter = lines.begin(); iter < lines.end(); iter++) {
    cout << *iter << endl;
  }

  return 0;
}

C++: #include <stdio.h>

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

C++: #include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-7
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(n) ((n) * (n))
#define N 35

int a[N];

int main(void) {
  int w;
  scanf("%d", &w);
  REP(i, w) {
    a[i] = i + 1;
  }
  int n;
  scanf("%d", &n);
  REP(i, n) {
    int x,y;
    scanf("%d,%d", &x, &y);
    x--,y--;
    swap(a[x],a[y]);
  }

  REP(i, w) {
    printf("%d\n", a[i]);
  }
}

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

int main(){
int w,n,a,b,c;
int number[30];
for(int i=0;i<30;i++){
	number[i]=i+1;}
cin>>w;
cin>>n;
for(int i=0;i<n;i++){
scanf("%d,%d",&a,&b);
c=number[a-1];
number[a-1]=number[b-1];
number[b-1]=c;}
for(int i=0;i<w;i++){
cout<<number[i]<<endl;}}

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

int main()
{
 int x[30];
 int w, n;
 
 cin >> w >> n;
 for(int i=0; i<w; i++) x[i] = i+1;

 int a, b;
 for(int i=0; i<n; i++){
  cin  >> a >> b;
  int tmp = x[a];
  x[a] = x[b];
  x[b] = tmp;
 }

 for(int i=0; i<w; i++){
  cout << x[i];
  if(i == w-1) break;;
  cout << '\n';
}

C++: #include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

void readCsv2(int *a, int *b) {
	char *buf = new char[512], *ptok;
	scanf("%511s", buf);
	if ((ptok = strtok(buf, ",")) != NULL) {
		*a = atoi(ptok);
		if ((ptok = strtok(NULL, ",")) != NULL) {
			*b = atoi(ptok);
		} else {
			b = 0;
		}
	} else {
		a = b = 0;
	}
	delete [] buf;
}

int main() {
	using namespace std;
	int w, n, a, b;
	vector<int> l;
	scanf("%d\n%d", &w, &n);
	for (int i = 1; i <= w; ++i) {
		l.push_back(i);
	}
	for (; n > 0; --n) {
		readCsv2(&a, &b);
		swap(l[a - 1], l[b - 1]);
	}
	for (vector<int>::iterator i = l.begin(); i != l.end(); ++i) {
		printf("%d\n", *i);
	}
	return 0;
}