Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

C++: #include <stdio.h>

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

int main(){
	int array[50];
	int w,n,a,b;

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

C++: #include <stdio.h>
#define MAX 30

int main(void){
    int w,n, tmp;
    int a,b;
    int lot[MAX+1]; // 1-origin

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

    return 0;
}

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

int main() {
  int w, n; 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) {
    char c;
    int a, b;
    cin >> a >> c >> b;
    --a; --b;
    swap(x[a], x[b]);
  }
  for (int i = 0; i < w; ++i) cout << x[i] << endl;
  return 0;
}

C++: #include<stdio.h>

int main(void){
int i,tate,yoko,a,b,temp ;
int array[] = {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} ;

scanf("%d %d",&tate,&yoko);

for(i=0; i<yoko; i++){
scanf("%d,%d",&a,&b);
a--;//for array index
b--;//for array index
temp = array[a] ;//swap values
array[a] = array[b] ;
array[b] = temp ;
}

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

return 0 ;
}

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

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

	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 >> comma >> 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<iostream>

int main(){
		int w,n,i,a[31],y,z,j;
		char x;
		std::cin>>w;
		std::cin>>n;
		for(i=1;i<=w;i++){
			a[i]=i;
		}
		for(i=0;i<n;i++){
			std::cin>>y>>x>>z;
			j=a[y];
			a[y]=a[z];
			a[z]=j;
		}
		for(i=1;i<=w;i++){
		std::cout<<a[i]<<std::endl;
		}


	return 0;
}

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

using namespace std;

int a[31];

int main()
{
    int w, n; scanf("%d\n%d", &w, &n);

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

    while (n--) {
        int b, c; scanf("%d,%d", &b, &c);
        swap(a[b], a[c]);
    }

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

C++: #include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


long res[30];
long from[30],to[30];

int main(){
	li w,n;
	cin>>w>>n;
	
	rep(i,w)res[i]=i;
	
	rin{
		scanf("%ld,%ld", &from[i], &to[i]);
	}
	
	rin{
		swap(res[from[i]-1],res[to[i]-1]);
	}
	
	rep(i,w)cout<<res[i]+1<<endl;
	
	return 0;
}

C++: #include <stdio.h>

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

int main(){
	int array[50];
	int w,n,a,b;

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

C++: #include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int w,n;
    int W[30],a,b;
    
cin>>w>>n;
    for(int i=1;i<=30;i++){
       W[i]=i;
    }
       for(int i=1;i<=n;i++){
        (cin>>a).ignore()>>b;
swap(W[a],W[b]);
    } 
        for(int i=1;i<=w;i++){
    cout<<W[i]<<endl;
        }
}

C++: //suhan lee, saitama university;
#include <stdio.h>


int main(){
  int list[30];
  int n,i,w,a,b,j,tmp,tmpp;
  scanf("%d%d", &w, &n);
  for(i=1;i<w+1;i++)
    list[i]=i;
  for(i=0;i<n;i++){
    scanf("%d%c%d", &a, &tmpp, &b);
    tmp=list[a];
    list[a]=list[b];
    list[b]=tmp;
 
  }
 for(j=1;j<w+1;j++)
    printf("%d\n",list[j]);
  
 return 0;
}

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

void swap( int &a, int &b )
{
 	int t;
	t = a;
	a = b;
	b = t;
	
	return;
}

int main()
{
	int w, n;
	int ans[30];
	std::vector<std::pair<int,int> > vec;
	
	scanf( "%d", &w );
	scanf( "%d", &n );
	for( int i = 0; i < n; i++ ){
		int a, b;
		scanf( "%d,%d", &a, &b );
		vec.push_back( std::make_pair<int,int>( a, b ) );
	}
	
	for( int i = 0; i < w; i++ ) ans[i] = i + 1;
	
	for( std::vector<std::pair<int,int> >::iterator it = vec.begin(); it != vec.end(); it++ ){
		swap( ans[ it->first - 1 ], ans[ it->second - 1 ] );	
	}
	
	for( int i = 0; i < w; i++ ){
	 	std::cout << ans[i] << std::endl;
	}

 	return 0;
}

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

using namespace std;

int main() {
	int w, n;
	int change[30][2];
	int line[30];
	cin >> w >> n;
	for (int i = 0; i < n; ++i) {
		scanf("%d,%d", &change[i][0], &change[i][1]);
	}
	
	for (int i = 0; i < w; ++i) {
		line[i] = i + 1;
	}
	for (int i = 0; i < n; ++i) {
		swap(line[change[i][0] - 1], line[change[i][1] - 1]);
		//for (int i = 0; i < w; ++i) {
		//	cout << line[i] << " ";
		//}
		//cout << endl;
		//cout << "--------------------------" << endl;
	}
	for (int i = 0; i < w; ++i) {
		cout << line[i] << endl;;
	}
}

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

int main()
{
  int w, n;
  cin >> w >> n;
  vector<int> amd(w);

  for (unsigned int i = 0; i < amd.size(); ++i)
    amd[i] = i+1;

  for (int i = 0; i < n; ++i) {
    string line;
    cin >> line;
    int a = atoi(line.substr(0, line.find_first_of(",", 0)).c_str());
    int b = atoi(line.substr(line.find_first_of(",", 0)+1).c_str());
    swap(amd[a-1], amd[b-1]);
  }
  for (unsigned int i = 0; i < amd.size(); ++i)
    cout << amd[i] << endl;

  return 0;
}

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

using namespace std;

int main(void) {
	int w, n, a[31], b[31], ans[31];
	
	cin >> w >> n;
	for (int i = 1; i <= n; i++) {
		scanf("%d,%d", &a[i], &b[i]);
	}
	for (int i = 1; i <= w; i++) {
		int point = i;
		for (int j = 1; j <= n; j++) {
			if (point == a[j]) {
				point = b[j];
			}
			else if (point == b[j]) {
				point = a[j];
			}
		}
		ans[point] = i;
	}
	for (int i = 1; i <= w; i++) {
		cout << ans[i] << endl;
	}
}