Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	n := nextInt()

	numbers := make([]int, w+1)
	for i := 1; i <= w; i++ {
		numbers[i] = i
	}

	for i := 0; i < n; i++ {
		line := nextString()
		words := strings.Split(line, ",")
		a, _ := strconv.Atoi(words[0])
		b, _ := strconv.Atoi(words[1])

		numbers[a], numbers[b] = numbers[b], numbers[a]
	}

	for i := 1; i <= w; i++ {
		fmt.Println(numbers[i])
	}
}

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

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
  int w, n;
  while (cin >> w >> n) {
    vector<int> vec;
    for (int i = 0; i < w; ++i) {
      vec.push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
      int a, b;
      scanf("%d,%d", &a, &b);
      a -= 1;
      b -= 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

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

int main(){
	int end[35];
	for(int i = 1;i<=30;i++)
		end[i]= i;
	int w;
	int n;
	
	cin >> w;
	cin >> n;
	for(int i = 1; i<=n;i++){
		int a,b;
		char c;
		cin >> a;
		cin >> c;
		cin >> b;
		int temp = end[b];
		end[b]=end[a];
		end[a]=temp;
	
	}
	for(int i = 1;i<=w;i++)
		cout << end[i] << endl;
		
	return 0;
}

C++: #include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(void)
{
  int w=0;
  int n=0;
  int v[50]={};
  int i=0;
  int a=0;
  int b=0;

  for(i=0;i<50;i++)
    v[i]=i+1;

  cin>>w>>n;

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

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

}

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

using namespace std;

int main(void){
	int w,n,*num,a,b,tmp;
	pair<int,int> *ln;
	char nul;

	cin >> w >> n;
	num = new int[w+1];
	ln = new pair<int,int>[n];

	for(int i=0;i<n;i++){
		cin >> a >> nul >> b;
		ln[i]=make_pair(a,b);
	}

	for(int i=1;i<=w;i++){
		tmp=i;
		for(int j=0;j<n;j++)
			tmp=tmp!=ln[j].first?tmp!=ln[j].second?tmp:ln[j].first:ln[j].second;
		num[tmp]=i;
	}
	for(int i=1;i<=w;i++)
		cout << num[i] << endl;

	delete [] ln;
	delete [] num;
	return 0;
}

C++: import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		//Scanner reader=new Scanner(System.in);
		String s=reader.readLine();
		int in=Integer.parseInt(s);
		//int in=reader.nextInt();
		int[] out=new int[in];
		for(int i=1;i<=in;i++)out[i-1]=i;
		//in=reader.nextInt();
		s=reader.readLine();
		in=Integer.parseInt(s);
		for(int i=0;i<in;i++){
			String s1=reader.readLine();
			String[] in1=s1.split(",");
			int a=Integer.parseInt(in1[0]);
			int b=Integer.parseInt(in1[1]);
			int tmp=out[a-1];
			out[a-1]=out[b-1];
			out[b-1]=tmp;
		}
		for(int i=0;i<out.length;i++)System.out.println(out[i]);
	}
}