Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func swap(ints []int, i, j int) {
	ints[i], ints[j] = ints[j], ints[i]
}

func main() {
	w := nextInt()
	// println(w)
	nums := make([]int, w)
	for i := range nums {
		nums[i] = i+1
	}
	n := nextInt()
	// println(n)
	for i := 0; i < n; i++ {
		info := nextString()
		// println(info)
		infos := strings.Split(info, ",")
		a, _ := strconv.Atoi(infos[0])
		b, _ := strconv.Atoi(infos[1])
		swap(nums, a-1, b-1)
	}
	for _, v := range nums {
		fmt.Println(v)
	}
}

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

using namespace std;
static const int MAXV = 32;

int main() {
  int w, n, A[MAXV], a, b, tmp;
  scanf("%d %d", &w, &n);
  for(int i=1;i<w+1;i++)
    A[i]=i;
  //for(int i=0;i<w+1;i++)
  //  printf("%d\n", A[i+1]);
  for(int i=0;i<n;i++) {
    scanf("%d,%d", &a, &b);
    //printf("%d %d\n", a, b);
    tmp=A[a];
    A[a]=A[b]; A[b]=tmp;
    //printf("\n%d %d %d %d %d\n", A[1], A[2], A[3], A[4], A[5]);
  }
  for(int i=1;i<w+1;i++)
    printf("%d\n", A[i]);
}

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

using namespace std;

int main() {
	int w, n;
	cin >> w >> n;

	int kuji[n], a[n], b[n];
	for (int i = 1; i <= w; i++) kuji[i] = i;

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

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

C++: // 2011/06/04 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	int w;
	cin >> w;

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

	int n;
	cin >> n;

	for(int i=0; i<n; i++){
		string str;
		cin >> str;

		for(int j=0; j<str.size(); j++)
			if(str[j]==',')
				str[j] = ' ';

		istringstream ist(str);
		int a, b;
		ist >> a >> b;

		int tmp = amd[a];
		amd[a] = amd[b];
		amd[b] = tmp;
	}

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

	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;
    string stri;
    cin>>w>>n;
    for(int i=0;i<n;i++){
        cin>>stri;
        str[i]=stri[0]-'0';
        fin[i]=stri[2]-'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>
using namespace std;

int main(){
int w = 0;
cin >> w ;
int n = 0;
cin >> n;
int i = 1;
int a[w];
for(i = 0;i < w;i++){
a[i] = i + 1;
}
for(i = 1;i <= n;i++){
int aa = 0;int bb = 0;
char split;
cin >> aa >> split >> bb ;
int c = 0;
c = a[aa - 1];
a[aa - 1] = a[bb - 1];
a[bb - 1] = c;
}
for(i = 0;i < w; i++){
cout << a[i] << endl;
}
    return 0;
}

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

int main(){
  int w, n;
  cin >> w >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    a.push_back(s.at(0) - '0');
    a.push_back(s.at(2) - '0');
  }
  vector<int> ans(w);
  for (int i = 1; i <= w; i++) {
    int tmp = i;
    for (int j = 0; j < a.size(); j += 2) {
      if (tmp == a.at(j)) {
        tmp = a.at(j + 1);
        continue;
      }
      if (tmp == a.at(j + 1)) {
        tmp = a.at(j);
        continue;
      }
    }
    ans.at(tmp - 1) = i;
  }
  for (int i = 0; i < w; i++) {
    cout << ans.at(i) << endl;
  }
}

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

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

	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <vector>

class DrawLots
{
private:
	int w;					// 縦線の数
	int n;					// 横線の数
	int a, b;				// 入れ替える数値(実際は-1することによってインデックスになる)
	std::vector<int> W;		// int型の動的配列Wを作成
public:
	DrawLots();
	~DrawLots();
	void Print();
	void ExchengeElement();
};

int main()
{
	DrawLots DL = DrawLots();
	DL.ExchengeElement();
	DL.Print();
}

DrawLots::DrawLots()
{
	std::cin >> w;
	std::cin >> n;
	
	W = std::vector<int>(w);

	W.assign(w, 1);

	for (int i = 0; i < w; i++)
	{
		W[i] = i + 1;
	}
}

DrawLots::~DrawLots()
{
}

void DrawLots::ExchengeElement()
{
	int tmp;
	for (int i = 0; i < n; i++)
	{
		
		scanf("%d,%d", &a, &b);

		tmp = W[a-1];
		W[a-1] = W[b-1];
		W[b-1] = tmp;

	}
}

void DrawLots::Print()
{
	for (unsigned int i = 0; i < W.size(); i++)
	{
		std::cout << W[i] << std::endl;
	}
}

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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int w, n;
	cin >> w >> n;
	vector<P> Vec(n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d,%d", &Vec[i].first, &Vec[i].second);
	}
	vector<int> start(w);
	for(int i = 0; i < w; ++i)
	{
		start[i] = i + 1;
	}
	vector<int> end(w);
	for(int i = 0; i < w; ++i)
	{
		for(int j = 0; j < n; ++j)
		{
			if(start[i] == Vec[j].first)
			{
				start[i] = Vec[j].second;
			}
			else if(start[i] == Vec[j].second)
			{
				start[i] = Vec[j].first;
			}
		}
		end[start[i] - 1] = i + 1;
	}
	for(int i = 0; i < w; ++i)
	{
		cout << end[i] << endl;
	}
}

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

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

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

  for (int i = 0; i < n; i++){
    scanf("%d,%d", &a, &b);
    c = r[a - 1];
    r[a - 1] = r[b - 1];
    r[b - 1] = c;
  }

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

  return 0;
}

C++: // include
// ----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>

// repetition
// ----------------------------------------------------------------------------
#define FOR(i, a, b) for (i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))

// debug
// ----------------------------------------------------------------------------
#define DEBUGNUM(x) printf("%d\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORNUM(i, a, b, x) FOR(i, a, b){ printf("%d ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) FOR(i, a, b){ printf("%c ", x[i]); }
#define DEBUGREPNUM(i, n, x) REP(i, n){ printf("%d ", x[i]); }
#define DEBUGREPCHAR(i, n, x) REP(i, n){ printf("%c ", x[i]); }

// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")

// constant
// ----------------------------------------------------------------------------
#define INF 1000000000

int main(void)
{
    int i, j;
    int num;
    int side_num;
    int a, b;

    scanf("%d", &num);

    int list[num];

    scanf("%d", &side_num);

    for (i = 0,j = 1; i < num; ++i, ++j){
        list[i] = j;
    }

    for (i = 0;i < side_num; ++i){
        scanf("%d, %d", &a, &b);

        list[a - 1] ^= list[b - 1];
        list[b - 1] ^= list[a - 1];
        list[a - 1] ^= list[b - 1];
    }

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

    return 0;
}