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>

void swap(int*, int, int);
void sepTwoNumbers(char*, int&, int&);
int char2Number(char*, int, int);

const int MAX_VIRTICAL_LINE = 30;
const int MAX_HORIZONTAL_LINE = 30;

int main(){
	int numOfVirticalLine;
	int numOfHorizontalLine;
	int amidaList[MAX_VIRTICAL_LINE] = {};

	for (int i = 0; i < MAX_VIRTICAL_LINE; i++)
	{
		amidaList[i] = i + 1;
	}

	std::cin >> numOfVirticalLine >> numOfHorizontalLine;
	for (int i = 0; i < numOfHorizontalLine; i++)
	{
		int line1, line2;
		char swapLineInfo[6];
		std::cin >> swapLineInfo;
		sepTwoNumbers(swapLineInfo, line1, line2);
		swap(amidaList, line1, line2);
	}
	for (int i = 0; i < numOfVirticalLine; i++)
	{
		std::cout << amidaList[i] << std::endl;
	}
	return 0;
}

void sepTwoNumbers(char* charOftwoNumber, int& number1, int& number2){
	int commaIndex;
	int endIndex;
	for (commaIndex = 0; charOftwoNumber[commaIndex] != ','; ++commaIndex);
	number1 = char2Number(charOftwoNumber, 0, commaIndex);
	for (endIndex = commaIndex; charOftwoNumber[endIndex] != '\0'; ++endIndex);
	number2 = char2Number(charOftwoNumber, commaIndex + 1, endIndex);
}

int char2Number(char* charNumber, int startDigit, int endDigit){
	int number = 0;
	for (int i = startDigit; i < endDigit; ++i){
		number *= 10;
		number += charNumber[i] - '0';
	}
	return number;
}

void swap(int* amidaList, int line1, int line2){
	int temp = amidaList[line1 - 1];
	amidaList[line1 - 1] = amidaList[line2 - 1];
	amidaList[line2 - 1] = temp;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int W, N, A[31], B[31], C[31];

	cin >> W >> N;

	for (int i = 1; i <= N; i++)
	{
		cin >> A[i] >> B[i];
	}

	for (int i = 1; i <= W; i++)
	{
		int t = i;

		for (int j = 1; j <= N; j++)
		{
			if (A[j] == t)
			{
				t = B[j];
			}
			else if (B[j] == t)
			{
				t = A[j];
			}
		}

		C[t] = i;
	}

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

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

	vector<int> tate(w);

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

	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a;
		cin.ignore(1);
		cin >> b;

		swap(tate[a - 1], tate[b - 1]);
	}

	for (auto temp : tate) {
		cout << temp << endl;
	}

}

C++: //#define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 30
int main(void)
{
	int w, n, a, b, x;
	int list[MAX] = { 0 };
	scanf_s("%d", &w);
	scanf_s("%d", &n);
	for (int i = 0; i < w;++i) {
		list[i] = i + 1;
	}
	for (int i = 0; i < n; ++i) {
		scanf_s("%d,%d", &a, &b);
		x = list[a - 1]; list[a - 1] = list[b - 1]; list[b - 1] = x;
	}
	for (int i = 0; i < w; ++i) {
		printf("%d\n", list[i]);
	}

}

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	int w; cin >> w;
	int n; cin >> n;
	int a, b;
	vector<int>v(w);
	char c;
	for (int i = 0; i < w; i++)v[i] = i + 1;
	for (int i = 0; i < n; i++) {
		cin >> a >>c>> b;
		swap(v[a - 1], v[b - 1]);
	}
	for (int i = 0; i < w; i++)cout << v[i] << endl;
	return 0;
}

C++: #include <cstdio>

using namespace std;

int line[32];
int w, n;

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

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

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

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

void swap(int a[], int k, int l) {
    int tmp = a[k];
    a[k] = a[l];
    a[l] = tmp;
}

int main(void) {
    int w, n, k, l;
    int a[31];
    cin >> w;
    cin >> n;
    for(int i = 1; i <= w; i++) {
        a[i] = i;
    }
    for(int j = 0; j < n; j++) {
        scanf("%d,%d", &k, &l);
        swap(a, k, l);
    }
    for(int i = 1; i <= w; i++) {
        printf("%d\n", a[i]);
    }
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

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

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

int main()
{
	int w, n, a, b;
	char comma;
	vector<int> vec;

	cin >> w;
	cin >> n;

	for (int i = 1; i <= w; i++)
	{
		vec.push_back(i);
	}

	for (int i = 0; i < n; i++)
	{
		cin >> a >> comma >> b;
		
		swap(vec[a - 1], vec[b - 1]);
	}

	for (auto a : vec)
	{
		cout << a << endl;
	}


	return 0;
}

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

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

C++: 
#include <iostream>
#include <vector>
#include <algorithm>

typedef std::pair<int, int> swap_command;

int w, n;
std::vector<int> vertical;
std::vector<swap_command> commands;

swap_command get_command_input()
{
	swap_command cmd;
	char dummy;
	std::cin >> cmd.first >> dummy >> cmd.second;
	return cmd;
}

void init()
{
	std::cin >> w;
	std::cin >> n;

//	std::cout << w << " " << n << std::endl;

	int i;
	for (i = 0; i < w; i++) {
		vertical.push_back(i+1);
	}

	for (i = 0; i < n; i++) {
		commands.push_back(get_command_input());
	}
}

void dump_vertical()
{
	std::cout << "vertical: ";
	for (int i = 0; i < w; i++) {
		std::cout << vertical[i] << ' ';
	}
	std::cout << std::endl;
}

void swap(swap_command cmd)
{
//	std::cout << "fist: " << cmd.first << " second: " << cmd.second << std::endl;
	int i = cmd.first-1;
	int j = cmd.second-1;
	int tmp = vertical[i];
	vertical[i] = vertical[j];
	vertical[j] = tmp;
//	dump_vertical();
}

void solve()
{
	for (std::vector<swap_command>::iterator i = commands.begin(); i != commands.end(); i++) {
		swap(*i);
	}
}

void output()
{
	for (std::vector<int>::iterator i = vertical.begin(); i != vertical.end(); i++) {
		std::cout << *i << std::endl;
	}
}

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;


 int main(){

   int w,n,u,t,p;
   cin >> w>>n;
   int a[w];
   for(int i=0; i<w;i++)
    a[i]=i+1;

   for(int i=0; i<n;i++){
     scanf("%d,%d\n",&u,&t);
     p=a[t-1]; a[t-1]=a[u-1];a[u-1]=p;
   }
   for(int i=0; i<w ;i++)printf("%d\n",a[i]);
 }