Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

C++: #include<stdio.h>

int main()
{
	int w,n,a,b,x,y;
	scanf("%d",&w);
	scanf("%d",&n);
	int m[30]={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};

	for(x=0;x<n;x++)
	{
		scanf("%d,%d",&a,&b);
		if(m[a-1]<=m[b-1])
		{
			y=m[b-1]-m[a-1];
			m[a-1]+=y;
			m[b-1]-=y;
		}
		else if(m[a-1]>m[b-1])
		{
			y=m[a-1]-m[b-1];
			m[b-1]+=y;
			m[a-1]-=y;
		}
	}

	for(x=0;x<w;x++)
	{
		printf("%d\n",m[x]);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
  int w, n;
  cin >> w >> n;
  vector<int> vec;
  vec.resize(w);
  for (int i = 0; i < vec.size(); ++i) {
    vec[i] = i + 1;
  }
  int a, b;
  for (int i = 0; i < n; ++i) {
    scanf("%d,%d", a, b);
    a -= 1;
    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 <iostream>

using namespace std;

int main(){
	int w, n;
	cin >> w >> n;
	int s[w];

	for(int i=0; i<w; i++){
		s[i] = i+1;
		while(n--){
		int a, b, c;
		cin >> a >> b;

		int tmp = s[a-1];
		s[a-1] = s[b-1];
		s[b-1] = tmp;
	}
	}

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

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

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

}

C++: //-------------
//include
//-------------
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <numeric>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef  long long LL;
typedef  vector<int> VI;
typedef  vector<string> VS;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(x) REP(i,SZ(x))cerr<<i<<x<<"="<<x[i]<<endl;
#define SIZE(x) cout<<sizeof(x)<<endl;
const int MOD = 1000000007;
//-------------
//cout
//-------------
#define COUTL(x) cout<<x<<endl
#define COUT(x) cout<<x
//-------------
//??£?¨??????\
//-------------
#define INTIN(x) int x; cin>>x;
#define INTINTIN(x,y) int x,y; cin>>x>>y;
#define STRIN(x) string x; cin>>x;
int main()
{
	VI amida;
	int w,n;
	cin >> w >> n;
	REP(i,w)
	{
		amida.push_back(i+1);
	}
	REP(i, n)
	{
		string temp;
		cin >> temp;
		int x = temp[0] - 48;
		int y = temp[2] - 48;
		int test;
		test = amida[x-1];
		amida[x - 1] = amida[y - 1];
		amida[y - 1] = test;
	}
	REP(i, w)
	{
		if (i == w-1)
		{
			COUT(amida[i]);
		}
		else
		{
			COUTL(amida[i]);
		}
	}
	#ifdef _DEBUG
	while(1);
#endif
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <numeric>
#include <string>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
    int W,N;
	cin >> W >> N;

	vector<int> ret(W);
    iota(begin(ret),end(ret),1);

    REP(i, N){
    	int a,b;
    	string str;
    	getline(cin,str,',');
    	a = stoi(str);

    	getline(cin,str,'\n');
    	b = stoi(str);

    	int buf = ret[a-1];
    	ret[a-1] = ret[b-1];
    	ret[b-1] = buf;
    }
    REP(i, W) cout << ret[i] << endl;
    return 0;
}

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

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

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

C++: #include<iostream>
int main(void){
	int w,n,x,y,temp;
	int a[31];
	char c;
	string str;
	istringstream is(str);
	for(int i = 0; i < 31; i++){
		a[i] = i;
	}
	scanf("%d %d",&w,&n);
	for(int i = 0; i < n; i++){
		getline(str,7);
		is >> x >> c >> y;
		temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

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

C++: #include <iostream>
using namespace std;
int main() {
    int line;
    int side;
    int sidenum1,sidenum2;
    int linenum[line];
    char waste;
    cin>>line>>side;
    for(int i=0; i<line; i++){
        linenum[i]=i+1;
    }
    for(int i=0; i<side; i++){
        cin>>sidenum1>>waste>>sidenum2;
        swap(linenum[sidenum1-1],linenum[sidenum2-1]);
    }
    for(int i=0; i<line; i++){
        cout<<linenum[i]<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <string>
#include <iomanip>
#include <math.h>
#include <limits>
#include <chrono>

using namespace std;

class amida
{
	int w;
	vector<int> va;
public:
	amida(int _w) : w(_w){
		for(int i = 0; i < w; i++){
			va.push_back(i);
		}
	}
	void swap(int, int);
	void output();
};

void amida::swap(int a1, int b1)
{
	int temp = va[a1-1];
	va[a1-1] = va[b1-1];
	va[b1-1] = temp;
}

void amida::output()
{
	for(int i = 0; i < w; i++)
		cout << va[i]+1 << '\n';
}

int main()
{
	int w, n;
	int a1, b1;
	cin >> w;
	amida am(w);
	cin >> n;
	for(int i = 0; i < n; i++){
		string str;
		cin >> str;
		const char* chtemp = str.c_str();
		char *ct;
		a1 = atoi(strtok_s((char*)chtemp, ",", &ct));
		b1 = atoi(strtok_s(NULL, ",", &ct));
		am.swap(a1, b1);
	}
	am.output();

	return 0;
}

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

int main()
{
	int w,n,i;
	cin >> w; cin >> n;
	int vertical_bar[w];
	// 配列を初期化
	for(i=0;i<w;i++){
		vertical_bar[i] = i+1;
	}
		
	for(i=0;i<n;i++){
		int a,b;
		scanf("%d, %d", &a,&b);
		swap(vertical_bar[a-1], vertical_bar[b-1]);
	}
	
	for(i=0;i<w;i++){
		cout << vertical_bar[i] <<endl;
	}
	
	return 0;
}

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

int main(){
	int end[35];
	for(int i = 1;i<=30;i++)
		end[i]= i;
	int w;
	int n;
	
	cin >> w;
	cin >> n;
	for(int i = n; i<=n;i++){
		int a,b;
		char c;
		cin >> a;
		cin >> c;
		cin >> b;
		int temp = end[b];
		end[b]=end[a];
		end[a]=temp;
	
	}
	for(int i = 1;i<=w;i++)
		cout << end[i] << endl;
		
	return 0;
}