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>
#include<vector>
 
int main()
{
    int w,n;
 
    char c;
 
  cin >> w >> n;
 
 vector<int> a(n);
 
    vector<int> b(n);
 
    vector<int> x(w);
 
    for(int i=0;i<n;i++)
    {
        std::cin >> a[i] >> c >> b[i];
    }
 
    for(int i=0;i<w;i++)
    {
        x[i]=i+1;
    }
 
    for(int i=0;i<n;i++)
    {
        int temp = x[a[i]-1];
 
        x[a[i]-1]=x[b[i]-1];
 
        x[b[i]-1]=temp;
    }
 
    for(int i=0;i<w;++i)
    {
      cout << x[i] << endl;
    }
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_W = 30;
int w, n;
int a, b;
int shff[MAX_W];

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

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

  rep(i, w) cout << shff[i] + 1 << endl;

  return 0;
}

C++: #include<iostream>
using namespace std;
void myswap(int *,int *);
int main(void){
	int abc[31],tate,yoko;
	cin>>tate>>yoko;
	for(int i=1;i<=tate;i++){
		abc[i]=i;
	}
	int pro1,pro2;
	char doll;
	for(int i=1;i<=yoko;i++){
		cin>>pro1>>doll>>pro2;
		myswap(&abc[pro1],&abc[pro2]);
	}
	for(int i=1;i<=tate;i++){
		cout<<abc[i]<<endl;
	}
	return 0;
}
void myswap(int *a,int *b){
	int c;
	c=*a;
	*a=*b;
	*b=c;
}

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(i==b){
				int tmp=data[a];
				data[a]=data[b];
				data[b]=tmp;
			}
		}
	}
	
	for(int i=1;i<=w;i++)cout<<data[i]<<endl;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int W,N;

int main()
{
	scanf("%d%d",&W,&N);
	vector<int> A(W + 1);
	for(int i = 1;i <= W;i++){
		A [i] = i;
	}

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

	return 0;
}

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

pair<int, int> p;
int a[31];

int main()
{
	int w, n, r;
	cin >> w >> n;
	for (int i = 1; i < w + 1; i++)
		a[i] = i;
	for (int i = 0; i < n; i++)
	{
		scanf("%d,%d", p.first, p.second);
		r = a[p.first];
		a[p.first] = a[p.second];
		a[p.second] = r;
	}
	for (int i = 1; i < w + 1; i++)
	{
		cout << a[i] << endl;
	}
	return 0;
}

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

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

C++: #include <cstdio>

int main()
{
    int amida[33];
    for (int i = 0; i <= 31; ++i)
        amida[i] = i;
    int w, n;
    int a, b;
    std::scanf("%d %d", &w, &n);
    for (int i = 0; i < n; ++i) {
        std::scanf("%d,%d", &a, &b);
        amida[32] = amida[a];
        amida[a] = amida[b];
        amida[b] = amida[32];
    }
    for (int i = 1; i <= w; ++i)
        std::printf("%d\n", amida[i]);
}

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 <stdio.h>
#include <algorithm>
using namespace std;

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

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

    while (n--) {
        int i,j;
        scanf("%d,%d", &i, &j);
        swap(a[i-1], a[j-1]);
    }

    for (int i = 0; i < w; ++i) {
        cout << a[i] << "\n";
    }

    return 0;
}

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


int main(void)
{
	int w,n;

	cin >> w >> n;

	int d[31];
	for(int i = 0; i < 31; i++)
		d[i] = i;
	int a,b;

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


	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef vector <int> vi;

int str2int(string text){
    stringstream ss;
    ss<<text;
    int tmp;
    ss>>tmp;
    return tmp;
}

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

	cin>>n;
	for (int i=0; i<n; i++){
		string text;
		cin>>text;
		string::size_type index = text.find( "," );

		int a, b;
		a = str2int(text.substr(0, index));
		b = str2int(text.substr(index+1));
		swap(x[a-1], x[b-1]);
	}

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

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

using namespace std;


int main(){

	int w[31];
	
	int n,m;
	int a,b;

	for(int i=0;i<31;i++)w[i]=i;

	cin>>n>>m;

	for(int i=0;i<m;i++){
		scanf("%d,%d",&a,&b);
		int temp=w[a];
		w[a]=w[b];
		w[b]=temp;
	}
	for(int i=1;i<=n;i++)cout<<w[i]<<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[w];
	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 <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
char temp;

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