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++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#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 ld long double
int main()
{
	int w, n;

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

C++: #include <iostream>
using namespace std;
int main(){
  int w,n;
  cin >> w >> n;
  int d[w+1];
  for(int i = 1 ; i <= w ; i++ )d[i] = i;
  for(int i = 1 ; i <= n ; i++ ){
    int a,b;
    char c;
    cin >> a >> c >> b;
    swap(d[a],d[b]);
  }
  for(int i = 1 ; i <= w ; i++ )cout << d[i] << endl;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>
using namespace std;
int main() {
	int w, n;
	cin >> w>> n;
	int temp[30];
	char s;
	int a[30], b[30];
	for (int i = 0;i < w;i++) {
		temp[i] = i + 1;
	}
	for (int i = 0;i < n;i++) {
		cin >> a[i] >> s >> b[i];
		int tempa;
			int tempb;
			tempa = temp[a[i]-1];
			tempb = temp[b[i]-1];
			temp[a[i]-1] = tempb;
			temp[b[i]-1] = tempa;
	}
	for (int i = 0;i < w;i++) {
		cout << temp[i] << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
    int w,n;
    int a[30]={-1};
    int j,k;
    int temp,temp1;
    
    while(cin >> w){
        
        if(w==0)break;

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

        cin >> n;       

        for(int i=0;i<n;i++){

            cin >> j >> temp >> k;
            
            temp1=a[j-1];
            a[j-1]=a[k-1];
            a[k-1]=temp1;

        }

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

    return 0;
}

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

int main(){
	int w,n;
	cin >> w >> n;
	int num[w + 1];
	for(int i = 1; i <= w; i++)num[i] = i;
	int a,b,temp;
	char c;
	while(cin >> a >> c >> b){
		temp = num[a];
		num[a] = num[b];
		num[b] = temp;
	}
	for(int i = 1; i <= w; i++)cout << num[i] << endl;
}

C++: #include <iostream>
#include <stdlib.h>

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++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#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) {
		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] = stoll(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<cstdio>
using namespace std;
int main(){
	int n,m;
	int row[30];
	cin >>n>>m;
	for(int i=0; i<n; i++){row[i] = i+1;}
	for(int i=0; i<m; i++){
		int a,b;
		scanf("%d,%d",&a,&b);
		int c = row[a-1];
		row[a-1] = row[b-1];
		row[b-1] = c;
	}
	for(int i=0; i<n; i++){cout <<row[i]<<endl;}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int n , w , i , j , a , b;
	int number[31] ;
	cin >> w ;
	cin >> n;
	for( i=1 ; i<=n ; i++ ){
		scanf( "%d,%d" , &a , &b );
		int x = number[a];
		number[a] = number[b];
		number[b] = x ;
	}
	for( i=1 ; i<=w ; i++ )
		cout << number[i] << endl;
}

C++: #include <cstdio>

using namespace std;

int main(void){
	int w, n, i, j, m[30][30], a, b, l;
	scanf("%d%d",&w,&n);
	for(i = 0;i < n;i++){
		for(j = 0;j < w;j++){
			m[i][j] = j;
		}
	}
	for(i = 0;i < n;i++){
		scanf("%d%*c%d",&a,&b);
		m[i][b - 1] = a - 1;
		m[i][a - 1] = b - 1;
	}
	for(i = 0;i < w;i++){
		l = i;
		for(j = n - 1;j >= 0;j--){
			l = m[j][l];
		}
		printf("%d\n",l + 1);
	}
	return 0;
}

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

using namespace std;

int main(void) {
	int w, n;
	cin >> w >> n;
	int *line = new int[w];
	for (int i = 0; i < w; i++)
		line[i] = i+1;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d,%d", &a, &b);
		a--, b--;
		line[a] ^= line[b];
		line[b] ^= line[a];
		line[a] ^= line[b];
	}
	for (int i = 0; i < w; i++)
		cout << line[i] << endl;
	delete[] line;
	return 0;
}

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

using namespace std;

int main() {
	int w, n;
	cin >> w >> n;

	int kuji[n];
	for (int i = 1; i <= w; i++) kuji[i] = i;

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

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

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

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

    cin >> w;

    for (i = 1; i <= w; i++){
        num[i] = i;
    }

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

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

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

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

C++: #include<stdio.h>
int main(void){
	int w,n,x,y,temp;
	int a[31];
	char str[7];
	for(int i = 0; i < 31; i++){
		a[i] = i;
	}
	scanf("%d %d",&w,&n);
	for(int i = 0; i < n; i++){
		getline(str,6);
		if(str[3] == ',')
			str[3] = ' ';
		else
			str[2] = ' ';
		sscanf(str,"%d %d",&x,&y);
		temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

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