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<cstdio>
using namespace std;
int main (){
	int w,N,d[30],sub;
	int a,b;

	cin>>w>>N;
	for(int j=1;j<=w;j++){
		d[j]=j;
	}
	for(int i=0;i<N;i++){
        scanf("%d,%d",&a,&b);
		sub=d[b];
		d[b]=c[a];
		c[a]=sub;
	}
	for(int k=1;k<=w;k++){
	cout<<d[k]<<endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int w, n;
vector <pair <int, int> > vp;

int main(){
    cin >> w >> n;
    rep(i, n){
        int va, ri;
        scanf("%d, %d", &va, &ri);
        vp.push_back(make_pair(va, ri)); 
    }
    vi ans;
    rep(i, w)ans.push_back(i + 1);
    rep(i, w){
        int out = i + 1;
        rep(j, vp.size()){
            if(out == vp[j].first)out = vp[j].second;
            else if(out == vp[j].second)out = vp[j].first;
        }
        ans[out - 1] = i + 1;
    }
    rep(i, w)cout << ans[i] << endl;
}

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

int main(){
   int W,n,i,z,*num;
   int a[30],b[30];
   char s;
   cin>>W>>n;
   
   num = new int[W];
   for(i=0;i<W;i++) num[i] = i+1;
   
   for(i=0;i<n;i++){
      cin>>a[i]>>s>>b[i];
   }
   for(i=0;i<n;i++){
      z = num[a[i]-1];
      num[a[i]-1] = num[b[i]-1];
      num[b[i]-1] = z;
   }
   for(i=0;i<W;i++){
      printf("%d\n",num[i]);
   }
   delete[] num;
   return 0;
}

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

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

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

int main(){
	int w, line[100], n, a, b, c;
	char x;

	cin >> w >> n;
	for (int i = 0; i < w; i++){
		line[i] = i + 1;
	}

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

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

	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	int W, N; scanf(" %d %d", &W, &N);
	vector<int> arr(W+1);
	rep(i,W+1) arr[i] = i;
	rep(i,N) {
		int a, b; scanf(" %d,%d", &a, &b);
		swap(arr[a], arr[b]);
	}
	rep(i,W) printf("%d\n", arr[i+1]);
	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	int w,n,t[30];
	scanf("%d%d",&w,&n);
	rep(i,w) t[i]=i;
	rep(i,n){
		string s;
		cin >> s;
		int a=0,b=0,cnt=0;
		for(;s[cnt]!=',';cnt++){
			a*=10;
			a+=(s[cnt]-'0');
		}
		for(cnt++;cnt<s.size();cnt++){
			b*=10;
			b+=(s[cnt]-'0');
		}
		swap(t[a-1],t[b-1]);
	}
	rep(i,w) printf("%d\n",t[i]+1);
	return 0;
}

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

using namespace std;

int main(){
	int VLineNum, HLineNum;
	cin >> VLineNum;
	cin >> HLineNum;

	int* Data = new int[VLineNum];//あみだくじNo.配列初期化
	for (int i = 0; i < VLineNum; ++i){
		Data[i] = i + 1;
	}

	int a, b, temp;//データロード&あみだくじ数値反転
	for (int i = 0; i < HLineNum; ++i){
		scanf("%d,%d", &a, &b);
		temp = Data[b-1];
		Data[b-1] = Data[a-1];
		Data[a-1] = temp;
	}

	for (int i = 0; i < VLineNum; ++i){//出力
		cout << Data[i] << endl;
	}

	delete [] Data;

	return 0;
}

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

int main()
{
  int w,n;
  int c[]={0};
  int a,b;
  //  int temp;

  scanf("%d",&w);
  scanf("%d",&n);

  for(int i=0; i<=n; i++){
    c[i]=i;
  }

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

  for(int i=1; i<=w; i++){
    printf("%d",c[i]);
  }
}

C++: #include<algorithm>
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int lot[33]; // くじ
  int w,n,a,b;
  for(int i=1;i<=30;i++)lot[i] = i;
  cin >> w >> n;

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

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

C++: #include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int ans[31]={};
int a[31],b[31];

int main() {

	int w,n;
	cin>>w;
	cin>>n;
	char c=',';
	rep(i,n)cin>>a[i]>>c>>b[i];
	for(int i=1; i<w+1; i++){
		int x=i;
		rep(j,n){
			if(x==a[j])x=b[j];
			else if(x==b[j])x=a[j];
		}
		ans[x]=i;
	}
	rep(i,w)cout<<ans[i+1]<<endl;

	return 0;
}

C++: #include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int w,n;
  int a[30],b[30],c[30];
  cin >> w >> n;
  for (int i = 0; i < w; i++) {
    c[i] = i+1;
  }
  char x;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> x >> b[i];
    // cout << a[i] << " " << b[i] << endl;
  }
  for (int i = 0; i < n; i++) {
    // swap(c[a[i]-1], c[b[i]-1]);
    int k = a[i] - 1;
    int j = b[i] - 1;
    int tmp = c[k];
    c[k] = c[j];
    c[j] = tmp;
  }
  for (int i = 0; i < w; i++) {
    cout << c[i] << endl;
  }
}

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


int main()
{
	int w, n, num[31];
	string s;
	cin >> w;
	fill(num, num + 31, 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 < 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;
}