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 <algorithm>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int main() {
  int w, n;
  cin >> w >> n;
  vector<int> a(n), b(n), x(w);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cin.ignore(numeric_limits<unsigned>::max(), ',');
    cin >> b[i];
  }
  for (int i = 0; i < w; i++)
    x[i] = i + 1;
  for (int i = 0; i < n; i++)
    swap(x[a[i] - 1], x[b[i] - 1]);
  for (int i = 0; i < w; i++)
    cout << x[i] << endl;
}

C++: #include <stdio.h>
main() {
  int d[31];
  int buf,i,w,n,a,b;
  scanf("%d%d",&w,&n);
  for(i=1;i<=w;i++) {
    d[i]=i;
  }
  for(i=0;i<n;i++) {
    scanf("%d,%d",&a,&b);
    buf=d[a];d[a]=d[b];d[b]=buf;
  }
  for(i=1;i<=w;i++) printf("%d\n",d[i]);
}

C++: int main(){

	int w, n;
	int num[30] = { 0 };
	int a, b;

	cin >> w;
	cin >> n;

	for (int i = 0; i<w; i++)
		num[i] = i + 1;

	for (int i = 0; i<n; i++){

		cin >> a >> b;

		int tmp = num[a-1];
		num[a-1] = num[b-1];
		num[b-1] = tmp;


	}


	for (int i = 0; i<w; i++)
		cout << num[i] << "\n";

	return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <vector>

class DrawLots
{
private:
	int w;					// 縦線の数
	int n;					// 横線の数
	int a, b;				// 入れ替える数値(実際は-1することによってインデックスになる)
	std::vector<int> W;		// int型の動的配列Wを作成
public:
	DrawLots();
	~DrawLots();
	void Print();
	void ExchengeElement();
};

int main()
{
	DrawLots DL = DrawLots();
	DL.ExchengeElement();
	DL.Print();
}

DrawLots::DrawLots()
{
	std::cin >> w;
	std::cin >> n;
	
	W = std::vector<int>(w);

	W.assign(w, 1);

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

DrawLots::~DrawLots()
{
}

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

		tmp = W[a-1];
		W[a-1] = W[b-1];
		W[b-1] = tmp;

	}
}

void DrawLots::Print()
{
	for (unsigned int i = 0; i < W.size(); i++)
	{
		std::cout << W[i] << std::endl;
	}
}

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

struct Pair {
	int x;
	int y;
	Pair(int xx,int yy) { x=xx; y=yy; }
};

int main()
{
	int w;						// 縦線の数(1~n)
	int n;						// 横線の数
	int x,y;
	int line_now;				// あみだの現在位置
	char comma;
	vector<Pair> pairs;			// 横線の移動経路を格納する

	cin >> w >> n;
	for(int i=0;i<n;i++) {
		cin >> x >> comma >> y;
		pairs.push_back(Pair(x,y));
	}
	vector<int> goals(w);			// [i]にi+1本目のあみだの値を格納
	for(int i=0;i<w;i++) {
		line_now = (i+1);
		for(int j=0;j<n;j++) {
			if(pairs[j].x==line_now)
				line_now = pairs[j].y;
			else if(pairs[j].y == line_now)
				line_now = pairs[j].x;
		}
		goals[line_now-1] = (i+1);
	}

	for(int i=0;i<goals.size();i++)
		cout << goals[i] << endl;

	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<cmath>
int main()
{
	int w;
	std::cin >> w;
	int*nums = new int[w];
	for(int i = 0; i < w; i++)
	{
		nums[i] = i + 1;
	}
	int n;
	std::cin >> n;
	for(int i = 0; i < n; i++)
	{
		int a, b;
		char foo;
		std::cin >> a >> foo >> b;
		int temp = nums[a - 1];
		nums[a - 1] = nums[b - 1];
		nums[b - 1] = temp;
	}
	for(int i = 0; i < w; i++)
	{
		std::cout << nums[i] << std::endl;
	}
	delete[]nums;
	return 0;
}

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

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

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

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

C++: //0011 Drawing Lots
//¢íÉ­¶ðø±¤I
//cüÌ{wA¡{Ì{hª^¦çêA
//ã©çÉhÂÌ¡üÌêª^¦çê½Æ«A±Ì¡üðÊßµ½Æ«ÌcüÌÔð¦æ
//È¨¡üÌîñÍA¡üªcüÌÊua,bÆÂÈªÁÄ¢éÆ·éÆA"a,b"Å\³êé
//w <= 30, h <= 30ª½³êéÆ·é

#include<iostream>
#include<algorithm>
using namespace std;

int main(void)
{
	const int N = 30;
	int w, h;
	int i;
	int a, b;

	int amida[N+1];	//âèÍ1©çnßÄ¢é©ç í¹é©@0ÈñÄÈ©Á½

	cin >> w >> h;

	//¡üªÈ¢Æ«Ìóµ
	for(i = 1; i <= w; i++)
		amida[i] = i;

	for(i = 0; i < h; i++)
	{
		//','ª´êÄ¢éÌÅòÎµÜµå¤
		char dummy;
		cin >> a >> dummy >> b;
		//¡üª éÆA½ÎÉÈèÜ·
		swap(amida[a], amida[b]);
	}
	
	for(i = 1; i <= w; i++)
	{
		cout << amida[i] << endl;
	}

	return 0;
}

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

int main() {
  int w,n,a1,b1,change;
  int num[40];
  string str;
  cin >> w;
  for(int i=1;i<w+1;i++) {
    num[i] = i;
  }
  cin >> n;
  for(int i=1,from = 0,to;i<n+1;i++) {
    cin >> str;
    to = str.find(",");
    a1 = strtol(str.substr(0,to).c_str(),NULL,0);
    b1 = strtol(str.substr(to+1).c_str(),NULL,0);
    change = num[a1];
    num[a1] = num[b1];
    num[b1] = change;
  }
  for(int i=1;i<w+1;i++) {
    cout << num[i] << endl;
  }
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int n, m, a[128];

int main() {
    scanf("%d%d", &n, &m);
    rep (i, n) a[i] = i+1;
    rep (_, m) {
        int x, y;
        scanf("%d,%d", &x, &y);
        x--, y--;
        swap(a[x], a[y]);
    }
    rep (i, n) printf("%d\n", a[i]);
    return 0;
}

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

int main(void){
  int w,n,a[31],tempi,temp2;
  char temp;
  for(int i = 0; i < 31; i++){
    a[i] = i + 1;
  }
  cin >> w >> n;
  for(int i = 0; i < n; i++){
    cin >> tempi >> temp >> temp2;
    swap(a[tempi - 1],a[temp2 - 1]);
  }
  for(int i = 0; i < w; i++){
    cout << a[i] << endl;
  }
  return 0;
}