Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	lines, _ := strconv.Atoi(sc.Text())
	l := make([]int, lines)
	for i := 0; i < lines; i++ {
		l[i] = i + 1
	}

	sc.Scan()
	rows, _ := strconv.Atoi(sc.Text())
	for i := 0; i < rows; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), ",")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])

		l[a-1], l[b-1] = l[b-1], l[a-1]
	}
	for _, j := range l {
		fmt.Println(j)
	}
}

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

using namespace std;

#define DATA_MAX 50

void swap( int& a , int& b );

int main(void)
{
	int w, n;
	int a, b;

	int data[DATA_MAX];

	cin >> w;
	cin >> n;

	for( int i = 0 ; i < DATA_MAX ; i++ )
	{
		data[i] = i+1;
	}

	for( int i = 0 ; i < n ; i++ )
	{
		scanf("%d , %d", &a , &b );
		swap( data[a-1] , data[b-1] );
	}
	for( int i = 0 ; i < w ; i++ )
	{
		cout << data[i] << endl;
	}

	return 0;
}

void swap( int& a , int& b )
{
	int temp;

	temp = a;
	a = b;
	b = temp;

	return;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef vector<int> vi;

int w,n,a,b;

int main() {
	scanf("%d", &w);
	vi v(w);
	rep(i,w) v[i] = i+1;

	scanf("%d", &n);
	rep(i,n) {
		scanf("%d,%d", &a, &b);
		swap(v[a-1], v[b-1]);
	}

	rep(i,w) printf("%d\n", v[i]);
}

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

using namespace std;

int w;//縦本の総本数
int n;//横棒の数
int D[30];//あみだの並び順


queue<pair<int,int> > que;
int a,b;
int temp;

int main(){
  scanf("%d %d",&w,&n);
  for(int i = 1;i <= w;i++){
    D[i] = i;
  }//あみだを初期化
  for(int i = 0;i < n;i++){
    scanf("%d,%d",&a,&b);
    que.push(pair<int,int>(a,b));
  }
  for(int i = 0;i <n;i++){
    a =que.front().first;
    b =que.front().second;
    temp = D[b];
    D[b] = D[a];
    D[a] = temp;
    que.pop();
  }
  for(int i = 1;i <=w;i++){
    printf("%d\n",D[i]);
  }

}

C++: #include<iostream>
#include<stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

void swap(int& x, int& y) {
  int tmp = x;
  x = y;
  y = tmp;
}

int main() {
  int w, n;
  int ws[30];
  cin >> w;
  REP(i,w) { ws[i] = i+1; }
  cin >> n;
  REP(i,n) { 
    string s;
    int a, b;
    cin>>s;
    a=atoi((s.substr(0,s.find(","))).c_str());
    b=atoi((s.substr(s.find(",")+1)).c_str());
    swap(ws[a-1], ws[b-1]);
  }
  REP(i,w) { cout << ws[i] << endl; }
  return 0;
}

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