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 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<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 1000000001
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int w, n;
int a[35];

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

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

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


	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

PII a[35];
signed main(void)
{
  int w, n;
  cin >> w >> n;
  REP(i, n) {
    int x, y;
    cin >> x; cin.ignore(); cin >> y;
    a[i] = MP(x, y);
  }
  int ans[50];
  REP(i, w) {
    int now = i+1;
    REP(j, n) {
      if(now == a[j].first) now = a[j].second;
      else if(now == a[j].second) now = a[j].first;
    }
    ans[now] = i+1;
  }
  FOR(i, 1, w+1) cout << ans[i] << endl;
  return 0;
}

C++: #include <stdio.h>

void swap(int *a, int *b){
int c=*a;
*a=*b;
*b=c;
return;
}

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

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int w,n;
  cin>>w>>n;
  vi a(w);
  REP(i,w)a[i]=i+1;
  REP(i,n){
    int x,y;
    scanf("%d,%d",&x,&y);
    --x;--y;
    swap(a[x],a[y]);
  }
  REP(i,w)cout<<a[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;
		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]+1 << endl;
	}
}

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

class Amidakuji{

public:
	int W;
	vector<int> array;//????´?1???????????????
	Amidakuji(int w);
	void Swap(int x,int y);
	void call();
};

//????????????????????????????????????
Amidakuji::Amidakuji(int w){

	for (int i = 0; i < w; i++){
		array.push_back(i+1);//[0,1,2,3,4]={1,2,3,4,5}
	}
	
	W = w;

}

void Amidakuji::Swap(int x,int y){

	//???????????£????????????array[]???????????????
	//int?????§???????????£????????§char???int?????????????????????-48;
	
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	

}

void Amidakuji::call(){

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

}

int main(){


	int w, n,loc,a,b;
	string text,str_a,str_b,str_v;

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);

			//????????¶?????§??????10,2??????????????¨??????{1,0,,,2}??????????????¢????????£?????????????????§??????????????????????????????????????????

			//?????????????????????????????????????????????????????§?????????????????£?????????????????\????????????????????£???
			loc=text.find(",", 0);
			str_a = text[0];
			for (int j = 1; j < loc; j++){
				str_v = text[j];
				str_a = str_a + str_v;

			}
			str_b = text[loc + 1];
			for (unsigned int j = loc + 2; j < text.length(); j++){
				str_v = text[j];
				str_b = str_b + str_v;
			}

			
			a = stoi(str_a);
			b = stoi(str_b);


			if (a != 0 && b != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(a, b);
				a = b = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

#define KANMA string(",")

int main(void) {
	int w, n;

	cin >> w;
	cin >> n;

	int *ary = new int[w];
	int i;
	for (i = 0; i < w; i++) {
		ary[i] = i + 1;
	}

	cin >> ws;
	for (i = 0; i < n; i++){
		int a, b;
		string str;
		string::size_type pos = 0;

		getline(cin, str);
		
		pos = str.find(KANMA, pos);
		a = atoi(str.substr(0, pos).c_str());
		pos += KANMA.length();
		b = atoi(str.substr(pos).c_str());

		int c = ary[a - 1];
		ary[a - 1] = ary[b - 1];
		ary[b - 1] = c;
	}

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

	return 0;
}

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


int main()
{
	int w, n, num[32];
	string s;
	cin >> w;
	fill(num, num + 32, 0);
	for (int i = 1; i < w + 1; i++){
		num[i] = i;
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		string l, r;
		int commapos;

		//カンマの左
		for (int i = 0;; i++){
			if (s[i] == ','){
				commapos = i;
				break;
			}
			else{
				l += s[i];
			}
		}

		//カンマの右
		for (int i = commapos + 1; i < (signed)s.length(); i++){
			r += s[i];
		}
		int left = atoi(l.c_str());
		int right = atoi(r.c_str());
		int temp = num[left];
		num[left] = num[right];
		num[right] = temp;
	}
	for (int i = 1; i < w + 1; i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int h,v,i,l,r,a[31];
char c;
for (i=0;i<31;i++) a[i]=i;
cin >> h >> v;
for (i=0;i<v;i++) {
	scanf("%d%c%d",&l,&c,&r);
	swap(a[l],a[r]);
}
for (i=1;i<=h;i++) cout << a[i] << endl;
return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int main(){
	int hig,wid,tmp,sta[35],fin[35],ans[35];
	char x;
	cin>>hig>>wid;
	for(int i=0;i<wid;i++){
		cin>>sta[i]>>x>>fin[i];
	}
	for(int i=1;i<=hig;i++){
		ans[i-1]=i;
	}
	for(int i=0;i<wid;i++){
		tmp=ans[sta[i]-1];
		ans[sta[i]-1]=ans[fin[i]-1];
		ans[fin[i]-1]=tmp;
	}
	for(int i=0;i<hig;i++){
		cout<<ans[i]<<endl;
	}
}