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

 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();
		a1 = atoi(strtok((char*)chtemp, ","));
		b1 = atoi(strtok(NULL, ","));
		am.swap(a1, b1);
	}
	am.output();

	return 0;
}

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

#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int w, n;

	cin >> w;
	cin >> n;

	vector<pair<int, int>> intersection(n);

	for(int i = 0; i < n; i++){
		scanf("%d,%d", &intersection[i].first, &intersection[i].second);
	}

	for(int i = 1; i <= w; i++){
		int r = i;
		for_each(intersection.rbegin(), intersection.rend(),
				[&](const auto& x){
					if(x.first == r){
						r = x.second;
					}else if(x.second == r){
						r = x.first;
					}
				}
		);
		cout << r << endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int w,n;
int num[30];
int main(){
    scanf("%d%d",&w,&n);
    for(int i=0;i<w;i++)num[i]=i;
    while(n--){
        int a,b;
        scanf("%d,%d",&a,&b);
        swap(num[--a],num[--b]);
    }
    for(int i=0;i<w;i++)printf("%d\n",num[i]+1);

    return 0;
}

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

int main()
{
    int w, n;
    cin >> n;
    cin >> w;
    int T[31];
    for (int i = 1; i <= n; i++)
    {
        T[i] = i;
    }
    for (int i = 0; i < w; i++) {
        int a, b;
        cin >> a >> b;
        swap(T[a], T[b]);
    }
    for (int i = 1; i <= n; i++)
        cout << T[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<iostream>
#include<vector>
#include<string>
#include<sstream>
using namespace  std;
int toInt(string s)
{
	int ret;
	stringstream ss;
	ss << s;
	ss >> ret;
	return ret;
}
int main()
{
	int w, n;
	vector<pair<int, int> > v;
	cin >> w >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		int index = s.find(',',0);
		int a = toInt(s.substr(0, index));
		int b = toInt(s.substr(index + 1));
		v.push_back(make_pair(a, b));
	}
	int numbers[40];
	for (int i = 0; i < w; i++)numbers[i] = i + 1;
	for (int i = 0; i < v.size(); i++)
	{
		int tmp = numbers[v[i].first - 1];
		numbers[v[i].first - 1] = numbers[v[i].second - 1];
		numbers[v[i].second - 1] = tmp;
	}
	for (int i = 0; i < w; i++)cout << numbers[i] << endl;
	return 0;
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int w, n, a, b;
    char c;
    cin >> w >> n;

    vector<int> kuji(w);
    REP(i, w) kuji[i] = i + 1;

    REP(i, n)
    {
        cin >> a >> c >> b;
        swap(kuji[a-1], kuji[b-1]);
    }

    REP(i, w) cout << kuji[i] << endl;
    
    return 0;
}

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

int main()
{
	int n,w,pos[31];


	cin>>w;
	for(int i=0;i<=w;i++) pos[i]=i;
	cin>>n;
	for(int i=0;i<n;i++){
		int left,right;
		string num,str_left,str_right;
		stringstream ss_left,ss_right;
		
		cin>>num;
		int j=0;
		while(num[j] != ','){
			j++;
		}
		str_left=num.substr(0,j);
		ss_left<<str_left;
		ss_left>>left;
		str_right=num.substr(j+1);
		ss_right<<str_right;
		ss_right>>right;
		
		cout<<"("<<left<<","<<right<<")"<<endl;

		int temp;
		temp=pos[left];
		pos[left]=pos[right];
		pos[right]=temp;
	}
	for(int i=1;i<=w;i++) cout<<pos[i]<<endl;
}

C++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(ll a=0;a<t;a++)
int main()
{
	ll w, n;

	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	ll a[32];
	roop(i, 32) {
		a[i] = i + 1;
	}
	roop(i, n) {
		string s;
		cin >> s;
		string d[2];
		roop(i, s.length()) {
			if (s[i] == ',') { d[0] = s.substr(0, i); d[i] = s.substr(i + 1); break; }
		}
		ll swap[2];
		roop(i, 2) {
			swap[i] = stoi(d[i]);
		}
		ll before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	roop(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int s[31];
    for (int i=1; i<=30; ++i) {
        s[i] = i;
    }

    int w, n;
    cin >> w >> n;
    int a,b;
    char delim;
    for (int i=0; i<n; ++i) {
        cin >> a >> delim >> b;
        swap(s[a],s[b]);
    }

    for (int i=1; i<=n; ++i) {
        cout << s[i] << "\n";
    }

    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	cin>>m>>n;
	vector<int>out(m);
	rep(i,m)out[m]=i+1;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		swap(out[a-1],out[b-1]);
	}
	rep(i,m)cout<<out[i]<<endl;

}

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

int A[40],B[40],ary[40];
int main(){
	int W,N;
	cin>>W>>N;
	char hog[9];
	for(int i=1;i<=N;i++){
		cin>>hog;
		if(strlen(hog)==3){
			A[i]=hog[0]-'0';
			B[i]=hog[2]-'0';
		}
		else if(strlen(hog)==5){
			A[i]=(hog[0]-'0')*10+(hog[1]-'0');
			B[i]=(hog[3]-'0')*10+(hog[4]-'0');
		}
		else if(hog[1]=','){
			A[i]=(hog[0]-'0');
			B[i]=(hog[2]-'0')*10+(hog[3]-'0');
		}
		else{
			A[i]=(hog[0]-'0')*10+(hog[1]-'0');
			B[i]=hog[3]-'0';
		}
	}
	for(int i=1;i<=W;i++){
		ary[i]=i;
	}
	for(int i=1;i<=N;i++){
		swap(ary[A[i]],ary[B[i]]);
	}
	for(int i=1;i<=W;i++){
		cout<<ary[i]<<endl;
	}
	return 0;
}