Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

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

C++: #include <stdio.h>

void swap(int *a, int *b){
int c=*a;
*a=*b;
*b=c;
return;
}

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

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

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

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

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

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

C++: #include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int w,n;
    cin>>w>>n;
    int c[40];
    for(int i=1;i<=w;i++){
        c[i]=i;
    }
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d,%d",&a,&b);
        swap(c[a],c[b]);
        
    }
    for(int i=1;i<=w;i++){
        cout<<c[i]<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int lot[31];
  for(int i=1;i<=30;i++){
    lot[i]=i;
  }
  int w,n;
  cin>>w>>n;
  for(int i=0;i<n;i++){
    int a,b;
    (cin>>a).ignore()>>b;
    swap(lot[a],lot[b]);
  }
  for(int i=1;i<=w;i++){
    cout<<lot[i]<<endl;
  }
  return 0;
}