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 <stdlib.h>

#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

/*
Drawing Lots

º}Ìæ¤È¢íÉ­¶ª èÜ·B±ÌáÅÍcüÌªT{ èAS{Ì¡üªø©êÄ¢Ü·B¡üÍcüðÜ½¢Åàæ¢ÆµÜ·B

}ÌãÅÍ 1, 2, 3, 4, 5 ÌÔÅ Á½àÌªAQÔÚÆSÔÚÌÔÅÌð·i±êð (2, 4) Ìæ¤É­jðµA³çÉA(3, 5)(1, 2)(3, 4) Ìð·ðµ½ÌÅA}ÌºÉ½Æ«ÍA4, 1, 2, 5, 3 ÉÈèÜµ½B

ÅÌóÔ@1, 2, 3, 4.... ªA^¦çê½¡_ÌXgi±ÌáÅÍA(2, 4)(3, 5)(1, 2)(3, 4) ðÊßµ½Ì¿AÇÌæ¤ÈÔÉÈé©ðoÍµÄI¹·évOðì¬µÄº³¢B
Input

cüÌ{ w (®Fw  30)
¡_Ì{ n (®Fn  30)
¡_Xg a1, b1 (®F¼pJ}æØè) ¡_Xg a2, b2 (®F¼pJ}æØè) .
.
.
¡_Xg an, bn (®F¼pJ}æØè)
Output

¶©çEÉA
1 ÔÚÌ_Éé
2 ÔÚÌ_Éé
.
.
w ÔÚÌ_Éé
Sample Input

5
4
2,4
3,5
1,2
3,4

Output for the Sample Input

4
1
2
5
3

*/

using namespace std;

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

int main()
{
	string s;
	int w, n;

	getline(cin, s);
	sscanf(s.c_str(), "%ld", &w);
	getline(cin, s);
	sscanf(s.c_str(), "%ld", &n);
	
	vector<int> v;
	for (int i = 0; i < w; i++)
	{
		v.push_back(i + 1);
	}
	
	for (int i = 0; i < n; i++)
	{
		int a, b;
		getline(cin, s);
		sscanf(s.c_str(), "%ld,%ld", &a, &b);
		swap(&v[a - 1], &v[b - 1]);
	}
	
	for (int i = 0; i < w; i++)
	{
		printf("%d\n", v[i]);
	}

	return 0;
}

C++: //
//Let's play Amidakuji.
//
//In the following example, there are five vertical lines and four horizontal lines.The horizontal lines can intersect(jump across) the vertical lines.
//
#include <iostream>
using namespace std;

typedef struct _INTPAIR {
    int a;
    int b;
} INTPAIR;

bool read(int& w, int& n, INTPAIR** ppArray);
bool initializeRod(const int w, int** ppArray);
bool swapRods(const int n, const INTPAIR* pConditions, int* pRods);
bool Write(const int w, const int* pRods);

int main()
{
    int w = 0, n = 0;
    INTPAIR* pConditions = NULL;
    int* pRods = NULL;

    // Start read conditions.
    if (!read(w, n, &pConditions))
        return 1;

    // Create rods.
    if (!initializeRod(w, &pRods))
        return 1;

    // Start swap rods.
    if (!swapRods(n, pConditions, pRods))
        return 1;

    // Output rods.
    if (!Write(w, pRods))
        return 1;
    
    delete[] pConditions;
    delete[] pRods;
}

bool read(int& w, int& n, INTPAIR** ppArray)
{
    char dummy;

    if (NULL == ppArray || NULL != *ppArray)
        return false;

    cin >> w;
    cin >> n;

    *ppArray = new INTPAIR[n];
    
    for (int i = 0; i < n; i++) {
        cin >> ((*ppArray) + i)->a;
        cin >> dummy;
        cin >> ((*ppArray) + i)->b;
    }

    return true;
}

bool initializeRod(const int w, int** ppArray)
{
    if (NULL == ppArray || NULL != *ppArray)
        return false;

    *ppArray = new int[w];

    for (int i = 0; i < w; i++) {
        *(*ppArray + i) = i + 1;
    }

    return true;
}

bool swapRods(const int n, const INTPAIR* pConditions, int* pRods)
{
    if (NULL == pConditions || NULL == pRods)
        return false;

    for (int i = 0; i < n; i++) {
        int idxL = (pConditions + i)->a - 1;
        int idxR = (pConditions + i)->b - 1;
        int tmp = 0;
        tmp = *(pRods + idxL);
        *(pRods + idxL) = *(pRods + idxR);
        *(pRods + idxR) = tmp;
    }

    return true;
}

bool Write(const int w, const int* pRods)
{
    if (NULL == pRods)
        return false;

    for (int i = 0; i < w; i++)
        cout << *(pRods + i) << endl;

    return true;
}

C++: #include <iostream>

using namespace std;

int main(){
	int w, n;
	int s[w];

	cin >> w >> n;

	for(int i=0; i<n; i++){
		int a, b;
		int c, d;
		cin >> a >> b;

		s[a] = c;
		s[b] = d;

		s[a] = d;
		s[b] = c;
	}

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

C++: #include <iostream>

using namespace std;

int main(){
    int w,n;
    int lots[30];

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

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

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

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

	std::vector<int> state(w);
	for (int i = 0; i < w; ++i)
		state[i] = i + 1;

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

		std::swap(state[a - 1], state[b - 1]);
	}

	for (auto&& v : state)
		std::cout << v << std::endl;
}

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

using namespace std;

void change2(int* a, int* b) {
	int tmp;
	
	tmp = *a;
	*a  = *b;
	*b  = tmp;
}

int main(void) {
	int w, n;
	int a, b;
	int value[30];
	char buf[256];
	
	for (int i=0; i<30; i++) {
		value[i] = i+1;
	}
	
	fgets(buf, sizeof(buf), stdin);
	sscanf(buf, "%d", &w);
	fgets(buf, sizeof(buf), stdin);
	sscanf(buf, "%d", &n);
	
	for (int i=0; i<n; i++) {
		fgets(buf, sizeof(buf), stdin);
		sscanf(buf, "%d,%d", &a, &b);
		change2(&value[a-1], &value[b-1]);
	}
	
	for (int i=0; i<w; i++) {
		printf("%d\n", value[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},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>
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 <iostream>
#include <stdio.h>

using namespace std;

int main(void) {

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

  int line[w+1], tmp = 0;
  for(int j = 1; j <= w; j++) {
    line[j] = j;
  }
  for(int k = 1; k <= n; k++) {
    tmp = line[a[k]];
    line[a[k]] = line[b[k]];
    line[b[k]] = tmp;
    tmp = 0;
  }

  for(int l = 1; l <= w; l++) {
    cout << line[l] << '\n';
  }

  return 0;
}

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

using namespace std; 

int main() {
    int w, n;
    scanf("%d%d", &w, &n);
    int num[w];
    for (int i = 0; i < w; i++) {
        num[i] = i+1;
    }
    while (n--) {
        int i, j;
        scanf("%d,%d", &i, &j);
        swap(num[i-1], num[j-1]);
    }
    for (int i = 0; i < w; i++) {
        printf("%d\n", num[i]);
    }
}