Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

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

C++: //
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

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

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int w = 0;
    cin >> w;
    
    int n = 0;
    cin >> n;
    
    int c[w];
    for(int i = 0; i < w; i++){
        c[i] = i + 1;
    }
    
    int a, b;
    int buffer;
    for (int i = 0; i < n; i++) {
        if(scanf("%d,%d",&a, &b) != EOF){;
            //printf("a: %d, b: %d ;; ", a, b);
            //printf("%d, %d -> ", c[a - 1], c[b - 1]);
            buffer = c[a - 1];
            c[a - 1] = c[b - 1];
            c[b - 1] = buffer;
            //printf("%d, %d\n", c[a - 1], c[b - 1]);
        }
    }
    for (int i = 0; i < w; i++) {
        printf("%d\n", c[i]);
    }
    
    
    return 0;
}

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


int main()
{
	int w, n, num[32];
	string s;
	cin >> w;
	fill(num, num + 32, 0);
	for (int i = 1; i < w + 1; i++){
		num[i] = i;
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		string l, r;
		int commapos;

		//カンマの左
		for (int i = 0;; i++){
			if (s[i] == ','){
				commapos = i;
				break;
			}
			else{
				l += s[i];
			}
		}

		//カンマの右
		for (int i = commapos + 1; i < (signed)s.length(); i++){
			r += s[i];
		}
		int left = stoi(l.c_str());
		int right = stoi(r.c_str());
		int temp = num[left];
		num[left] = num[right];
		num[right] = temp;
	}
	for (int i = 1; i < w + 1; i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

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