Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

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

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

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

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

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>

#define EPS (1e-8)

using namespace std;

int main() {
  int w, n;
  while(cin >> w >> n, w) {
    int a[n][2];
    int r[w];
    int t;
    for (int i = 0; i < n; i++) {
      cin >> a[i][0];
      cin.ignore();
      cin >> a[i][1];
    }
    for (int i = 0; i < w; i++) {
      r[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
      t = r[a[i][1] - 1];
      r[a[i][1] - 1] = r[a[i][0] - 1];
      r[a[i][0] - 1] = t;
    }
    for (int i = 0; i < w; i++) {
      cout << r[i] << endl;
    }
    w = 0;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;

#define PI (3.1415926535)
#define EPS (1e-10)
bool eq(double a, double b){
  return abs(a-b) < EPS;
}

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