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<algorithm>
using namespace std;
int main(){
	int w,n,a,b;
	int num[30];
	cin>>w>>n;
	for(int i=0;i<w;i++)num[i]=i+1;
	while(n--){
		cin>>a;
		cin.ignore(1);//改行まで最大１文字読み飛ばし
		cin>>b;
		swap(num[a-1],num[b-1]);
	}
	for(int i=0;i<w;i++)
		cout<<num[i]<<endl;
	return 0;
}

C++: #include <iostream>

int main(){
	int a,b,c,g,h;
	std::cin>>a>>b;
    int d[a];
    for(int e=1;e<=a;e++){
    	d[e]=e;
    	
	}
	for(int f=0;f<b;f++){
		std::cin>>g;
		std::cout<<",";
		std::cin>>h;
		c=d[g];
		d[g]=d[h];
		d[h]=c;
	}
	for(int i=1;i<=a;i++){
		std::cout<<d[i]<<std::endl;
	}
	return 0;
}

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

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

vector<int> makeRangeArray(int n)
{
        static vector<int> vec;
        for(int i = 1; i <= n; i++){
                vec.push_back(i);
        }

        return vec;
}

void exchangeInArray(vector<int>& vec, int a, int b)
{
        if(a <= 0 || b <= 0)
                throw "エラー発生";

        a--;
        b--;

        swap(vec[a],vec[b]);
}

int reader(string str, int& a, int& b)
{
        int i;

        a = 0;
        b = 0;
        for(i=0; str[i] != ','; i++)
        {
                a *= 10;
                a += str[i] - '0';
        }

        for(i++; str[i];i++){
                b *=10;
                b += str[i] - '0';
        }
}

int main()
{
        try{
                int w;
                int n;
                cin >> n;
                cin >> w;
                vector<int> vec = makeRangeArray(n);
                for(int i=0;i<w;i++){
                        int a,b;
                        string str;
                        cin >> str;
                        reader(str, a, b);
                        exchangeInArray(vec, a, b);
                }

                for(auto x:vec){
                        cout << x << endl;
                }
        }
        catch (char *str){
                cout << str << endl;
        }
}

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

int main(){
  int tate,yoko,n,m,a,b,c[31];
  cin>>tate;
  for(int i=1;i<=tate;i++)
    c[i]=i;
  cin>>yoko;
  for(int i=0;i<yoko;i++){
    cin>>a>>b;
    swap(c[a],c[b]);
  }
  for(int i=1;i<=tate;i++)
    cout<<c[i]<<endl;
  return 0;
}

C++: #include <stdio.h>

int main(){
	int i,w,n,a,b,tmp,line[30];
	scanf("%d",&w);
	scanf("%d",&n);
	for(i = 0;i < w;i++) line[i] = i + 1;
	for(i = 0;i < n;i++){
		scanf("%d,%d",&a,&b);
		tmp = line[a - 1];
		line[a - 1] = line[b - 1];
		line[b - 1] = tmp;
	}
	for(i = 0;i < w;i++) printf("%d\n",line[i]);
}

C++: #include <iostream>
#include<algorithm>
#include<array>

using namespace std;

int W,N;

int main(){

	cin>>W>>N;
	array<pair<int,int>,30> p;
	char c;
	for(int i=0;i<N;i++){
		cin>>p[i].first>>c>>p[i].second;
		p[i].first--;
		p[i].second--;
	}
	int cc[30]={0};
	for(int j=0;j<W;j++){
		int co=j;
		for(int i=0;i<N;i++){
			
			if(p[i].first==co){
				co=p[i].second;
			}
			else if(p[i].second==co){
				co=p[i].first;
			}
		}
		cc[co]=j;
		//cout<<co<<endl;
	}
	for(int i=0;i<W;i++){
		cout<<cc[i]+1<<endl;
	}

	return 0;
}

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

int main()
{
	ifstream ifs("Text.txt");
	int w,wl[30],n,a,b,c;
	char ch;
	for(int i=0;i<30;i++){
		wl[i]=i;
	}
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		cin>>ch;
		cin>>b;
		c=wl[a];
		wl[a]=wl[b];
		wl[b]=c;
	}
	for(int i=0;i<w;i++){
		cout<<wl[i+1]<<endl;
	}
}

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

int main(){
    int w,n;
    
    int line[35]={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,31,32,33,34,35};
    cin>>w>>n;
    for(int i=0; i<n; i++){
        int a,b;
       (cin>>a).ignore()>>b;
        swap(line[a],line[b]);
    }
    for(int i=0; i<w;i++){
        cout<<line[i]<<endl;
    }
        return 0;
}

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

int n;
int m;
int ans[1000];

int main() {
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    ans[i] = i;
  }

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

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

C++: #include<stdio.h>
int main()
{
  int sen[31],y,i,k,hon,m,h;
  scanf("%d",&hon);
  for(i=1;i<=hon;i++)sen[i]=i;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d,%d",&m,&h);
    y=sen[m];
    sen[m]=sen[h];
    sen[h]=y;
  }
  for(i=1;i<=hon;i++)printf("%d\n",sen[i]);
  return 0;
}

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

using namespace std;

void swap(int&, int&);

int main(){
  int w, n, a, b;
  char c;
  vector<int> x;

  cin >> w;
  cin >> n;

  for(int i=0; i<=w; ++i)
    x.push_back(i);

  for(int i=0; i<n; ++i){
    cin >> a >> c >> b;
    swap(x[a], x[b]);
  }

  for(int i=1; i<=w; ++i)
    cout << x[i] << endl;

  return 0;
}

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

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>
#include <typeinfo>
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) {
		int swap[2]; char kanma;
		cin >> swap[0] >> kanma >> swap[1];
		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<stdio.h>
#include<stdlib.h>

using namespace std;

int main(void) {


	//0011
	int Line[31], w=0, n=0, a, b, tmp;
	cin >> w;
	cin >> n;
	for (int i=0; i < 30; i++) {
		Line[i] = i;
	}
	for (int j = 0; j < n; j++) {
		scanf("%d,%d", &a, &b);
		tmp = Line[a];
		Line[a] = Line[b];
		Line[b] = tmp;
	}
	for (int k = 1; k <= w; k++) {
		cout << Line[k] << endl;
	}


	return 0;
}