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++: /*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

void out1(vector<int> a) {
	for (size_t i = 0; i < a.size(); i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}

int main() {
	int w, n;
	cin >> w;	// ???????????°
	cin >> n;	// ?¨?????????°
	vector<int> begin(n);
	vector<int> end(n);
	vector<int> location(w);
	int num1 = 0;
	int num2 = 0;

	// ??\???
	for (size_t i = 0; i < n; i++)
	{
		scanf_s("%d,%d", &begin[i], &end[i]);
		cout << begin[i] << end[i] << endl;
	}

	// location????????????
	for (size_t i = 0; i < w; i++)
	{
		location[i] = i + 1;
		
	}
	
	// ????????\??¬????????§????????????
	for (size_t i = 0; i < w; i++)
	{
		vector<int> tmp(w,0);
		out1(tmp);
		tmp[i] = location[i];
		cout << "----i = " << i << "?????¨???----" << endl;
		for (size_t j = 0; j < n; j++)
		{
			if (begin[j] == location[i])
			{
				
				cout << begin[j] << "???" << end[j] << "?????\???????????????" << endl;
				location[i] = end[j];
			}
			else if (end[j] == location[i])
			{
				cout << end[j] << "???" << begin[j] << "?????\???????????????" << endl;
				location[i] = begin[j];
			}
			out1(location);
		}
	}
	// ???????????????
	vector<int> output(w,0);
	for (size_t i = 0; i < w; i++)
	{
		output[location[i]-1] = i;
	}

	// ???????????¨???????????????????????°??????1????¶????
	for (size_t i = 0; i < w; i++)
	{
		cout << output[i]+1 << endl;
	}


	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.
	
						[picture]
	
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.

Your task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., w are assigne to the vertical lines from left to right.
 */
 
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

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

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

using namespace std;
void lots(int len,int a,int b,int array[]){
    int buffer[5];
    for(int i = 0;i < len; i++){
        if(i == a-1){
            buffer[i] = array[b-1];
        }
        else if(i == b-1){
            buffer[i] = array[a-1];
        }
        else{
            buffer[i] = array[i];
        }
    }
    for(int i = 0; i < len; i++){
        array[i] = buffer[i];
    }

}

int main(){
    int len,duration,a,b;
    cin >> len;
    cin >> duration;
    int array[len];
    for(int i = 0; i < len; i++){
        array[i] = i+1;
    }
    for(int i = 0; i < duration; i++){
        scanf("%d,%d",&a,&b);
        lots(len,a,b,array);
    }
    for(int i = 0; i < len; i++){
        cout << array[i] << endl;
    }
}

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

using namespace std;

int horizontalLine,verticalLine;
int A,B;
char UserInput[10];

int main()
{
        cin >> verticalLine;
        cin >> horizontalLine;

        int NumberExist[verticalLine];
        for(int y = 1; y <= verticalLine; y++)
        {
            NumberExist[y-1] = y;
        }

        for(int x = 1; x <= horizontalLine; x++)
        {
            cin >> UserInput;
            A = UserInput[0] - '0';
            B = UserInput[2] - '0';
            int TempVariable;
            TempVariable = NumberExist[A-1];
            NumberExist[A-1] = NumberExist[B-1];
            NumberExist[B-1] = TempVariable;

        }

        for(int z = 0; z < verticalLine; z++)
        {
            cout << NumberExist[z] << endl;
        }


}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
using namespace std;

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

C++: #include<iostream>

int main(){
	int w,n,data[31];
	std::cin>>w>>n;
	for(int i=1;i<=w;i++)data[i]=i;
	for(int i=0;i<n;i++){
		int a,b,d;
		char c;
		std::cin>>a>>c>>b;
		d=data[a];
		data[a]=data[b];
		data[b]=d;
	}
	for(int i=1;i<=w;i++)std::cout<<data[i]<<std::endl;	
	return 0;
}

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

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

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


	return 0;
}

C++: #include <stdio.h>

int main()
{
    int w, n, a, b, t, s[30];

    scanf("%d %d", &w, &n);
    for (int i = 0; i < w; i++)
        s[i] = i + 1;

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

    for (int i = 0; i < w; i++)
        printf("%d\n", s[i]);

    return 0;
}

C++: 
/*
 * main.cpp
 *
 *  Created on: 2011/04/08
 *      Author: satoki
 *      13:05 ~ 6:03
 */
#include <iostream>
#include <string.h>
using namespace std;

int iW;
int iN;
int iA;
int iB;

int iX[31];

void init() {
}

bool input() {
  int i, tmp;
  if (scanf("%d", &iW) == EOF) return false;
  for (i = 0; i <= iW; i++) {
    iX[i] = i;
  }
  scanf("%d", &iN);
  for (i = 0; i < iN; i++) {
    scanf("%d,%d", &iA, &iB);
    tmp = iX[iA];
    iX[iA] = iX[iB];
    iX[iB] = tmp;
  }
  return true;
}

void manage() {
}

int main() {
  int i;
  init();
    input();
    manage();
    for (i = 1; i <= iW; i++) {
      printf("%d\n", iX[i]);
    }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstdio>
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;
		scanf("%d,%d",&HorizonalLine.Left,&HorizonalLine.Right);
		swap(StartingPoint[HorizonalLine.Left-1], StartingPoint[HorizonalLine.Right-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}