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 <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int w,n;

  cin >> w >> n;

  vector<int> line(w);
  for(int i = 0; i < w; i++) {
    line[i]=i;
  }
  int t = 0;
  while(t < n) {
    int a,b;
    char c;
    cin >> a >> c  >> b;
    line[a-1] ^= line[b-1];
    line[b-1] ^= line[a-1];
    line[a-1] ^= line[b-1];
    
    t++;
  }

  for(auto l : line)
    cout << l+1 << endl;
  
  return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

int dp[60];

int main()
{
	int w(0),n(0);
	REP(i, 60){
		dp[i] = i;
	}
	cin >> n >> w;
	REP(i, w){
		int a, b;
		char c;
		scanf("%d,%d", &a,&b);
		swap(dp[a], dp[b]);
	}
	REP(i, n){
		cout << dp[i+1] << endl;
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(inti =a; i<n; i++)
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;
}

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

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

C++: #include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;

int sosuu(int n);

int main(){
    int w=0;
    scanf("%d",&w);
    
    int n=0;
    scanf("%d",&n);
    
    int DL[w+1];
    for(int i=1; i<=w; i++){
        DL[i]=i;
    }
    
    for(int i=0; i<n; i++){
        int a,b;
        char c;
        scanf("%d%c%d",&a,&c,&b);
        int temp;
        temp=DL[a];
        DL[a]=DL[b];
        DL[b]=temp;
    }
    
    for(int i=1; i<=w; i++){
        printf("%d\n",DL[i]);

    }
    
}

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

using namespace std;

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

int main() {
  int w, n, a[40][2], pos[40];
  cin >> w >> n;
  rep (i, n) scanf("%d,%d", a[i], a[i] + 1);
  rep (i, n) --a[i][0], --a[i][1];
  rep (i, w) pos[i] = i;
  rep (i, n) swap(pos[a[i][0]], pos[a[i][1]]);
  rep (i, w) cout << pos[i] + 1 << endl;
  return 0;
}

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

	return 0;
}

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

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

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

int main(){
	int w, n, i, tmp, a, b;
	cin>>w;
	cin>>n;
	vector<int> vw(w);
	vector<vector<int> > vn(n, vector<int>(2));
	for(i=0;i<w;i++) vw[i] = i+1;
	for(i=0;i<n;i++){
		scanf("%2d,%2d",&a, &b);
		vn[i][0] = a-1;
		vn[i][1] = b-1;
		
		tmp = vw[(vn[i][0])];
		vw[(vn[i][0])] = vw[(vn[i][1])];
		vw[(vn[i][1])] = tmp;
	}
	for(i=0;i<w;i++) cout << vw[i] << endl;
	return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;






int main()
{
	int n, w;
	int a[30], b[30],c[30];
	cin >> w;
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf_s("%d,%d", &a[i], &b[i]);
		
	}
	for (int i = 1; i <= w; i++) {
		c[i] = i;
	}
	for (int i = 0; i < n; i++) {
		swap(c[a[i]], c[b[i]]);
	}
	for (int i = 1; i <= w; i++) {
		cout << c[i] << endl;
	}
	

}

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

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

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

int main() {
  int w, n, a, b, r[31], i, t;

  for (i = 1; i <= 30; i++) {
    r[i] = i;
  }

  cin >> w >> n;
  for (i = 0; i < n; i++) {
    scanf("%d,%d", &a, &b);
    t = r[a];
    r[a] = r[b];
    r[b] = t;
  }

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

  return 0;
}

C++: #include<iostream>
#define MAX_W 30
#define MAX_N 30
using namespace std;

typedef pair<int, int> P;
P line[MAX_N + 1];
int n, w;
char comma;
int result[MAX_W + 1];

void input()
{
	cin >> w >> n;
	for (int i = 1; i <= n; i++)
		cin >> line[i].first >> comma >> line[i].second;
}

void solve()
{
	int pos;
	for (int i = 1; i <= w; i++)
	{
		pos = i;
		for (int j = 1; j <= n; j++)
		{
			if (line[j].first == pos)
				pos = line[j].second;
			else if (line[j].second == pos)
				pos = line[j].first;
		}
		result[pos] = i;
	}
}

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

int main()
{
	input();
	solve();
	print();
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int w,n,str[30],fin[30],ans[31],add[31],now=0;
    char stri[7];
    cin>>w>>n;
    for(int i=0;i<n;i++){
        cin>>stri;
        if(stri[3]=='\0'){
            str[i]=stri[0]-'0';
            fin[i]=stri[2]-'0';
        }
        else if(stri[4]=='\0'&&stri[1]==','){
            str[i]=stri[0]-'0';
            fin[i]=(stri[2]-'0')*10+(stri[3]-'0');
        }
        else if(stri[4]=='\0'){
            str[i]=(stri[0]-'0')*10+(stri[1]-'0');
            fin[i]=stri[3]-'0';
        }
        else {
            str[i]=(stri[0]-'0')*10+(stri[1]-'0');
            fin[i]=(stri[3]-'0')*10+(stri[4]-'0');
        }
        add[i]=fin[i]-str[i];
    }
    for(int i=1;i<=w;i++){
        now=i;
        for(int j=0;j<n;j++){
            if(now==str[j])now+=add[j];
            else if(now==fin[j])now-=add[j];
        }
        ans[now]=i;
    }
    for(int i=1;i<=w;i++)cout<<ans[i]<<endl;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int ver, hor;

  cin >> ver;
  cin >> hor;
  int nums[ver];
  for (int i = 0; i < ver; i++)
    nums[i] = i+1;
  
  int tmp, a, b;
  for (int i = 0; i < hor; i++) {
    scanf("%d,%d", &a, &b);
    a--; b--;
    tmp = nums[a];
    nums[a] = nums[b];
    nums[b] = tmp;
  }

  for (int i = 0; i < ver; i++)
    cout << nums[i] << endl;
  return 0;
}