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<vector>
#include<cstdio>
using namespace std;
int main(){
  int n,m;
  cin >>n>>m;
  vector<int> lot;
  for(int i=0; i<n; i++) lot.push_back(i+1);
  for(int i=0,a,b,c; i<m; i++){
    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<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

//typedef int kz;
//typedef long kz;
typedef long long kz;

kz gcd(kz a,kz b) { if(b==0) return a; else gcd(b,a%b); }
kz lcm(kz a,kz b) { return a*b/gcd(a,b); }

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/


int main(){
    int mod=1000000007;
    int n,w;
    scanf("%d",&w);
    scanf("%d",&n);
    int x[w];
    int r[n][2];
    int ans[w];

    for (int i=0;i<n;i++) {
        scanf("%d,%d",&r[i][0],&r[i][1]);
    }
    for (int i=1;i<=w;i++) {
        int tmp=i;
        for (int j=0;j<n;j++) {
            if (tmp==r[j][0]) tmp=r[j][1];
            else if (tmp==r[j][1]) tmp=r[j][0];
        }
        ans[tmp-1]=i;
    }
    for (int i=0;i<w;i++) {
        printf("%d\n",ans[i]);
    }
    return 0;
}

C++: #include<stdio.h>

int main(){
int tate,yoko,bou[30][2],j,x,kekka[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31},i=0;
scanf("%d %d",&tate,&yoko);
for(j=0;j<yoko;j++){
scanf("%d , %d",&bou[j][1],&bou[j][2]);
}
for(i=1;i<tate+1;i++){
x=i;
for(j=0;j<yoko;j++){
if(bou[j][1]==x){
x=bou[j][2];
}
else if(bou[j][2]==x){
x=bou[j][1];
}
}
kekka[x-1]=i;
}
for(j=0;j<tate;j++){
printf("%d\n",kekka[j]);
}
}

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

struct THorizonalLine
{
	int Left;
	int Right;
};

int main()
{
	int w;
	cin >> w;
	int n;
	cin >> n;
	vector<int> StartingPoint(w);
	for(int i = 0; i < w; i++){
		StartingPoint[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		THorizonalLine HorizonalLine;
		char Dummy;
		cin >> HorizonalLine.Left >> Dummy >> HorizonalLine.Right;
		swap(StartingPoint[HorizonalLine.Left-1], StartingPoint[HorizonalLine.Right-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}

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

int main(void){
	int w,n;
	int a,b;
	int line[30];
	int i;

	for(i=0;i<30;i++){
		line[i]=i+1;
	}
	cin >> w;
	if(w<=30&&w>0){
		cin >> n;
		for(i=0;i<n;i++){
			cin >> a >> b;
			if(a>0&&b>0&&a<=w&&b<=w) swap(line[a-1],line[b-1]);
		}
		for(i=0;i<w;i++){
			cout << line[i];
			if(i==w-1) cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

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

int main(){
	int w;
	int n;
	while(cin>>w>>n){
	vector<int> x(w);
	for(int i=0;i<w;i++)x[i]=i+1;

	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int a=s[0]-'0';
		int b=s[2]-'0';
		a--;
		b--;
		int tmp=x[a];
		x[a]=x[b];
		x[b]=tmp;
	}
	for(int i=0;i<w;i++)cout<<x[i]<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
int array[31];

void swap(int a, int b) {
  int c = array[a];
  array[a] = array[b];
  array[b] = c;
}

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

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

using namespace std;

int main(){
	int w, n;
	int a[30], b[30];
	int now[30];
	int x, y;

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


	for (int j = 0; j < n; j++){
		for (int i = 0; i < w; i++){
			if (now[i] == a[j]){
				now[i] = b[j];
				now[b[j]] = a[j];
				break;
			}
		}
	}

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

	return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int W, N; cin >> W >> N;
	vector<int>nums(W);
	iota(nums.begin(), nums.end(), 1);
	while (N--) {
		int a, b;
		scanf("%d,%d", &a, &b);
		a--; b--;
		swap(nums[a], nums[b]);
	}
	for (int i = 0; i < W; ++i)cout << nums[i] << endl;
	return 0;
}

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

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

C++: #include <iostream>
#include<cstdio>
using namespace std;
int main (){
	int w,N,d[30],c[30];
	int a,b;

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

	return 0;
}

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

using namespace std;

int main() {

	int no[30] = {0};
	int N,m,a,b;
	char connma;

	cin >> N;
	cin >> m;

	for (int i = 0; i < N; i++) {
		no[i] = i+1;
	}
	
	for (int i = 0; i < m; i++) {
		cin >> a >> connma >> b;
		swap(no[a - 1], no[b - 1]);
	}

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

	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)
 
typedef vector<int> vi;
 
int main()
{
    int w, n;
    scanf("%d%d", &w, &n);
 
    vi line(w);
    rep(i, w) line[i] = i+1;
    rep(i, n){
        int a, b;
        scanf("%d,%d", &a, &b);
        swap(line[a-1], line[b-1]);
    }
 
    rep(i, w) printf("%d\n", line[i]);
 
    return 0;
}

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

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

C++: #include<stdio.h>

int main(){

int x[32][2]={};
int w,n;

scanf("%d",&w);
scanf("%d",&n);
for(int i=0;i<=w;i++)
x[i][0]=i;

for(int i=0;i<n;i++)
{
int a1,a2;
scanf("%d,%d",&a1,&a2);
int t=x[a1][0];x[a1][0]=x[a2][0];x[a2][0]=t;
}

for(int i=1;i<=w;i++)
printf("%d\n",x[i][0]);

return 0;
}