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

int main()
{
    int w, n;
    char c;

    cin >> w >> n;

    list<vector <int>> routes;

    for (vector<int> r(2); n-- && cin >> r[0] >> c >> r[1];)
        routes.push_front(r);

    for (int i = 1, pos = i; i <= w; pos = ++i) {
        for (auto r: routes)
            if (r[0] == pos)
                pos = r[1];
            else if(r[1] == pos)
                pos = r[0];

        cout << pos << endl;
    }

    return 0;
}

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

C++: #include<cstdio>
#include<cmath>
 
//#include<iostream>
using namespace std;
 
int main(){
    int w, n, a, b, i, t, ar[31];
	for(i=0; i<31; ++i) ar[i]=i;

	scanf("%d %d", &w, &n);
    for(i=0; i<n; ++i){
		scanf("%d,%d", &a, &b);
		t=ar[a]; ar[a]=ar[b]; ar[b]=t;
	}
	for(i=1; i<w+1; ++i)	printf("%d\n", ar[i]);

    return 0;
}

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

int main()
{
	int tmp[30][2];
	int num[30];
	int num2[30];
	int w,n,i,j;
	
	//??????????????????
	for(j=0; j<2; j++){
		for(i=0; i<30; i++){
			tmp[i][j]=0;
			}
	}
	for(i=0; i<30; i++){
		num[i]=1+i;
		num2[i]=1+i;
	}
	
	//????£?w????¨??£?n?????°?????????
	cin >> w >> n;
	
	//?¨??£????????´??????????
	for(i=0; i<n; i++){
		scanf("%d,%d",&tmp[i][0],&tmp[i][1]);
	}
	
	//??\???????????????
	for(i=0; i<w; i++){		//????£??????°????????°?????????
		for(j=0; j<n; j++){		//?¨??£??????°????????°?????????
			//??\?????????
			if((num[i]==tmp[j][0]) || (num[i]==tmp[j][1])){
				if(num[i]==tmp[j][0]){
					num[i]=tmp[j][1];
				}else{
					num[i]=tmp[j][0];
				}		
			}
		}
	}
	for(i=0; i<w; i++){
		cout << "test" << endl;
		j=num[i];
		num2[j-1]=i+1;
	}
	
	
	
	
	//????????¨???
	for(i=0; i<w; i++){
		cout << num2[i] << endl;
	}
	
	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 <algorithm>
#include <cstdio>
#include <memory>

using namespace std;

int main() {
  int w, n;
  scanf("%d", &w);
  scanf("%d", &n);

  unique_ptr<int[]> order(new int[w]);
  for (int i = 0; i < w; ++i) { order[i] = i + 1; }

  for (int i = 0; i < n; ++i) {
    int j, k;
    scanf("%d,%d", &j, &k);
    swap(order[j - 1], order[k - 1]);
  }

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

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int
main ()
{
  int w, n;
  cin >> w >> n;
  vector < int >list (w);
  vector < int >::iterator it;
  int i = 1;
  for (it = list.begin (); it != list.end (); ++it)
    *it = i++;
  for (w = 0; w < n; w++)
    {
      int b, a;
      scanf ("%d%*c%d", &b, &a);
      swap (list[b - 1], list[a - 1]);
    }
  for_each (list.begin (), list.end (),[](int n)
	    {
	    cout << n << endl;});

}

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

using namespace std;

int main(void) {
	while(1) {
		int w, n;
		int lin[30][2] = { 0 };
		int ans[30];
		int now;
		
		cin >> w;
		if( cin.eof() )		break;
		cin >> n;
		for(int i = 0; i < n; i++) {
			scanf("%d,%d", &lin[i][0], &lin[i][1]);
		}
		for(int i = 1; i <= w; i++) {
			now = i;
			for(int j = 0; j < n; j++) {
				if(now == lin[j][0]) {
					now = lin[j][1];
				} else if(now == lin[j][1]) {
					now = lin[j][0];
				}
			}
			ans[now - 1] = i;
		}
		for(int i = 0; i < w; i++) {
			cout << ans[i] << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <deque>
#include <string>
#include <cstdio>
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,n) loop(i,0,n)

using namespace std;

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

    int vec[40];
    for (int i = 0; i < 40; i++)vec[i] = i;
    for (int i = 0; i < n; i++){
        int a, b;
        char com;
        cin >> a >> com >> b;
        int t = vec[a];
        vec[a] = vec[b];
        vec[b] = t;
    }
    for (int i = 1; i <= w; i++){
        cout << vec[i] << endl;
    }
}

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

void swap(int a[],int x,int y){
  int t=a[x];
  a[x]=a[y];
  a[y]=t;
  return;
}

int main(){
  int a[100]={};
  int n,w;
  cin>>w>>n;
  for(int i=1;i<=w;i++){
    a[i]=i;
  }
  for(int i=0;i<n;i++){
    int e,f;
    scanf("%d,%d",&e,&f);
    swap(a,e,f);
  }
  for(int i=1;i<=w;i++){
    cout<<a[i]<<endl;
  }
}

C++: #include <iostream>

using namespace std;

void swap(int &x,int &y);
int main(){
  int *line=NULL,w,n;
  
  cin>>w;
  cin>>n;

  line=new int[w];
  for( int i=0;i<w;i++ )
    line[i]=i+1;
  for( int i=0;i<n;i++ ){
    int a,b;
    char c;
    cin>>a>>c>>b;
    swap(line[a-1],line[b-1]);
  }
  for( int i=0;i<w;i++ )
    cout<<line[i]<<endl;
  delete line;
  line = 0;
  return 0;
}

void swap(int &x,int &y){
  x^=y;
  y^=x;
  x^=y;
}

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

using namespace std;

int main()
{
    int w, n, a, b;
    char c;
    cin >> w >> n;
    vector<int> v(w);
    for (int i = 0; i < w; i++) {
        v[i] = i+1;
    }
    for (int i = 0; i < n; i++) {
        cin >> a >> c >> b;
        a--; b--;
        swap(v[a], v[b]);
    }
    for (int &x: v) {
        cout << x << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(0);
	int w; cin >> w;
	vector<int> v(w); REP(i, w) v[i] = i+1;
	int n; cin >> n;
	REP(i, n) {
		int a, b;
		scanf("%d,%d", &a, &b); --a, --b;
		swap(v[a], v[b]);
	}
	REP(i, w) {
		cout << v[i] << endl;
	}
}

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