Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	n := nextInt()

	numbers := make([]int, w+1)
	for i := 1; i <= w; i++ {
		numbers[i] = i
	}

	for i := 0; i < n; i++ {
		line := nextString()
		words := strings.Split(line, ",")
		a, _ := strconv.Atoi(words[0])
		b, _ := strconv.Atoi(words[1])

		numbers[a], numbers[b] = numbers[b], numbers[a]
	}

	for i := 1; i <= w; i++ {
		fmt.Println(numbers[i])
	}
}

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

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

using std::cin;

int main()
{
    int vert_num;
    cin >> vert_num;
    std::vector<int> vert(vert_num);

    for (auto i = 0; i < vert_num; i++) {
        vert.at(i) =  i + 1;
    }

    int horiz;
    cin >> horiz;

    while (horiz--) {
        int swap1, swap2;
        char x;
        cin >> swap1 >> x >> swap2;

        int tmp = vert.at(swap1 - 1);
        vert.at(swap1 - 1) = vert.at(swap2 - 1);
        vert.at(swap2 - 1) = tmp;
    }

    for (auto i = 0; i < vert_num; i++) {
        std::cout << vert.at(i) << std::endl;
    }

    return 0;
}

C++: #include <iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define ARRAY_MAX 50

int main(){
	// your code goes here
  int vertical,horizontal;
  int tmp;
  int array[ARRAY_MAX][ARRAY_MAX];
  int num[ARRAY_MAX];
  char c;

  cin >> vertical >> horizontal;

  for(int i = 0;i < vertical;i++){
    num[i] = i+1;
  }

  for(int i = 0;i < horizontal;i++){
    cin >> array[i][0] >> c >> array[i][1];
  }
  
 
  for(int i = 0;i < vertical;i++){
    tmp = num[array[i][0]-1];
    num[array[i][0]-1] = num[array[i][1]-1];
    num[array[i][1]-1] = tmp;
  }

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

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
  int amida[31];
  for ( int i = 0; i < 31; i++ ) amida[i] = i;
  int w,n; cin >> w >> n;
  for ( int i = 0; i < n; i++ ) {
    int a,b; char ch;
    cin >> a >> ch >> b;
    swap(amida[a],amida[b]);
  }
  for ( int i = 1; i <= w; i++ ) cout << amida[i] << endl;;
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
using namespace std;
int w,n;
int stick[50],stick2[50]={0};
vector<pair<int,int> > pii;
int main(){
  cin>>w>>n;
  for(int i=1;i<=w;i++)
    stick[i-1]=i;
  for(int i=0;i<n;i++){
    string a;
    cin>>a;
    pii.push_back(make_pair(a[0]-'0',a[2]-'0'));
    }
  for(int i=0;i<w;i++){
     for(int j=0;j<n;j++){
    if(stick[i]==pii[j].first)
      stick[i]=pii[j].second;
    else if(stick[i]==pii[j].second)
      stick[i]=pii[j].first;
     }
  }
  for(int i=0;i<w;i++){
    for(int j=1;j<=w;j++){
      if(stick[i]==j){
	stick2[j-1]=i+1;
	break;
      }
    }
  }
  for(int i=0;i<w;i++)
    cout<<stick2[i]<<endl;
  return 0;
}