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 <string>
#include <cstdlib>

using namespace std;

#define KANMA string(",")

int main(void) {
	int w, n;

	cin >> w;
	cin >> n;

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

	cin >> ws;
	for (i = 0; i < n; i++){
		int a, b;
		string str;
		string::size_type pos = 0;

		getline(cin, str);
		
		pos = str.find(KANMA, pos);
		a = atoi(str.substr(0, pos).c_str());
		pos += KANMA.length();
		b = atoi(str.substr(pos).c_str());

		int c = ary[a - 1];
		ary[a - 1] = ary[b - 1];
		ary[b - 1] = c;
	}

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

	return 0;
}

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


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

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int h,v,i,l,r,a[31];
char c;
for (i=0;i<31;i++) a[i]=i;
cin >> h >> v;
for (i=0;i<v;i++) {
	scanf("%d%c%d",&l,&c,&r);
	swap(a[l],a[r]);
}
for (i=1;i<=h;i++) cout << a[i] << endl;
return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int main(){
	int hig,wid,tmp,sta[35],fin[35],ans[35];
	char x;
	cin>>hig>>wid;
	for(int i=0;i<wid;i++){
		cin>>sta[i]>>x>>fin[i];
	}
	for(int i=1;i<=hig;i++){
		ans[i-1]=i;
	}
	for(int i=0;i<wid;i++){
		tmp=ans[sta[i]-1];
		ans[sta[i]-1]=ans[fin[i]-1];
		ans[fin[i]-1]=tmp;
	}
	for(int i=0;i<hig;i++){
		cout<<ans[i]<<endl;
	}
}

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

int main(){
  string sa,sb;
  int w,n,a,b,c;
  int num[n];
  cin>>w>>n;
  for(int i=0;i<w;i++)
    num[i] = i+1;
  for(;n>0;n--){
    getline(cin,sa,',');
    getline(cin,sb,'\n');
    a = atoi(sa.c_str())-1;
    b = atoi(sb.c_str())-1;
    c = num[a];
    num[a]=num[b];
    num[b] = c;
  }
  for(int i=0;i<w;i++)
    cout << num[i] << endl;
  return 0;
}

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

int main(void){
  int s[31];
  int w,n;

  for(int i = 0;i<31;i++) s[i] = i;

  cin >> w;
  cin >> n;

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

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

  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){
		std::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 <iostream>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

typedef struct{
    int l;
    int r;
}tint;
int main(){
    vector<tint> lines;
    tint ins;
    int w,n;
    int*ans = new int(w);
    cin >> w >> n;
    for(int i=0;i<n;i++){
        scanf("%d,%d",&ins.l,&ins.r);
        lines.push_back(ins);
    }
    for(int i=1;i<=w;i++){
        int a=i;
        for(int j=0;j<n;j++){
            if(lines[j].l==a){
                a=lines[j].r;
            }else if(lines[j].r==a){
                a=lines[j].l;
            }
        }
        ans[a-1]=i;
    }
    for(int i=1;i<=w;i++){
        cout << ans[i-1] << endl;
    }
    delete ans;
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int main(){
  int n,w;
  cin >>n>>w;
  vector<int> lot;
  for(int i=0; i<n; i++) lot.push_back(i+1);
  while(w--){
    int a,b,c;
    scanf("%d,%d",&a,&b);
    c = lot[a-1];
    lot[a-1] = lot[b-1];
    lot[b-1] = c;
  }
  for(int i=0; i<n; i++) cout <<lot[i]<<endl;
  return 0;
}

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

void swap(int *a, int *b) {
	int x = *a;
	*a = *b;
	*b = x;
}
int main() {
	int w, n, a, b, amida[31];
	char c;
	cin >> w;
	for (int i = 1;i <= w;i++) { amida[i] = i; }
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a >>c>> b;
		swap(&amida[a], &amida[b]);
	}
	for (int i = 1;i <= w;i++)
		cout << amida[i] << endl;
}

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

using namespace std;

int main(){
    int w, n, a, b;
    vector<pair<int, int>> h_lines;
    cin >> w >> n;
    
    while(scanf("%d,%d",&a,&b)+1){
     h_lines.push_back(pair<int, int>(a,b));   
    }
    
    
    for (int i = 0; i < w; ++i){
        int where = i+1;
        for (auto line:h_lines){
            if (line.first == where){
                where = line.second;
            } else if (line.second == where){
                where = line.first;
            }
        }
        cout << where << endl;
    }
    
 return 0;   
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i, f, n) for (int i = f; i < n; ++i)
#define rep(i, n) reep(i, 0, n)


int main(){
    int w,n,a,b,t;
    int arr[30];
    scanf("%d", &w);
    scanf("%d", &n);
    rep(i,w) arr[i] = i+1;
    while(n--) {
        scanf("%d,%d", &a, &b);
        t = arr[a-1];
        arr[a-1] = arr[b-1];
        arr[b-1] = t;
    }
    rep(i,w) printf("%d\n", arr[i]);
}

C++: #include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(){
    int w, n;
    int d[31];
    while(cin >> w >> n){
        for(int i=1;i<=w;i++) d[i] = i;
        for(int i=0;i<n;i++){
            string s; cin >> s;
            istringstream iss(s);
            for(int j=0;j<s.size();j++)
                if(s[j]==',') s[j] = ' ';
            int a, b; iss >> a >> b;
            swap(d[a], d[b]);
        }
        for(int i=1;i<=w;i++) cout << d[i] << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
int w,n; cin >> w >> n;
int a[31];
rep(i,0,w) a[i] = i+1;

rep(i,0,n) {
int x,y;
scanf("%d,%d",x,y);
swap(a[x-1],a[y-1]);
}
rep(i,0,n) cout << a[i] << endl;
return 0;
}