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 <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define rrep(i,n) for(int i = n-1;i >=0;i--)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, sum = 0, h, w;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
int main() {
    int n, m; string s; cin >> n >> m; vector<int> v(n);
    rep(i, n) v[i] = i + 1;
    rep(i, m) {
        int a,b;char c;
        cin >> a >> c >> b;
        swap(v[a-1], v[b-1]);
    }for (int i : v) cout << i << endl;
}

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

using namespace std;

int w, n;

struct bar {
	int a, b;
};

vector <bar> v;
int order[35];

int main() {
	scanf("%d", &w);
	scanf("%d", &n);
	
	for (int i=0; i<n; i++) {
		bar r;
		scanf("%d, %d", &r.a, &r.b);
		v.push_back(r);
	}
	
	for (int i=1; i<=w; i++) {
		int s = i;
		for (int j=0; j<n; j++) {
			if (v[j].a==s) s = v[j].b;
			else if (v[j].b==s) s = v[j].a;
		}
		order[s] = i;
	}
	
	for (int i=1; i<=w; i++) cout << order[i] << endl;
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() { 
  int n, w, a[31], ai, bi;  
  cin >> w >> n;
  for(int i=1; i<=w; i++) {
    a[i] = i;
  } 
  for(int i=0; i<n; i++) { 
    scanf("%d%*c%d",&ai, &bi); 
    swap(a[ai],a[bi]); 
  } 
  for(int i=1; i<=w; i++) { 
    cout << a[i] << endl; 
  }  
  return 0;
}

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

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

	return 0;
}

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 (int j = loc + 2; j < (signed) 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<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
using namespace std;

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

C++: #include <iostream>

using namespace std;

int main()
{
    int w, n;
	char dummy;
    cin>>w;
	cin>>n;
	int *data = new int [w];
	int *a = new int [n];
	int *b = new int [n];
	for(int i=0;i<n;++i)
	{
		cin>>a[i]>>dummy>>b[i];
	}
	for(int i=0;i<w;++i)
	{
		data[i]=i+1;
	}
	for(int i=0;i<n;++i)
	{
		swap(data[a[i]-1],data[b[i]-1]);
	}
	for(int i=0;i<w;++i)
	{
		cout<<data[i]<<endl;
	}
}

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

int main(){
	int w;
	while(cin>>w){
		vector<pair<int, int> > all;
		int n;
		cin>>n;
		for(int i=0; i<n; i++){
			int a, b;
			scanf("%d,%d", &a, &b);
			cout<<a<<b;
			all.push_back(pair<int, int>(a, b));
		}
		reverse(all.begin(), all.end());
		for(int i=1; i<=w; i++){
			int ima = i;
			for(int j=0; j<n; j++){
				if(all[j].first == ima){
					ima = all[j].second;
				} else if(all[j].second == ima){
					ima = all[j].first;
				}
			}
			cout<<ima<<endl;
		}
	}
}

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


void exchange( int& x, int& y )
{
    int tmp;

    tmp = x;
    x = y;
    y = tmp;
}

int main()
{
    int w, n;                           //w縦線の数, n横線の数

    cin >> w;
    cin >> n;

    int vline[w];                       //縦線を格納する配列

    for( int i = 0; i < w; i++ )        //引数0から1,2,3という数字が入る
    {
        vline[i] = i + 1;
    }

    for( int i = 0; i < n; i++ )
    {
        int from, to;                   //fromからtoへ。int型のみ受け付けたい。
        char extra;                      //','は余分な入力

        cin >> from >> extra >> to;

        exchange( vline[from-1]  , vline[to-1] );
    }

    for( int i = 0; i < w; i++)
        cout << vline[i] << endl;

    return 0;

}

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

#define MAX_N 30
#define MAX_W 30

void swap(int* a, int* b){
    int temp=0;
    temp = *a;
    *a = *b;
    *b = temp;
}

int main(){
    int w,n,ans[MAX_W];
    int a[MAX_N], b[MAX_N];

    scanf("%d",&w);
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf( "%d, %d", &a[i], &b[i]);
    }

    // Initialize
    for(int i = 0; i < w; i++){
        ans[i] = i + 1;
    }

    // Solve
    for(int i = 0; i < n; i++){
        swap(&ans[ a[i] - 1 ], &ans[ b[i] - 1 ]);
    }

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



    return 0;
}