Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

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

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;
  
int main() {
int w,n; cin >> w >> n;
int a[31];
rep(i,0,w) a[i] = i+1;
  
rep(i,0,n) {
int x,y;
scanf("%d,%d",&x,&y);
swap(a[x-1],a[y-1]);
}
rep(i,0,n) cout << a[i] << endl;
return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int h,v,i,l,r;
int a[30];
for (i=0;i<30;i++) a[i]=i;
cin >> h >> v;
for (i=0;i<v;i++) {
	cin >> l >> r ;
	swap(a[l],a[r]);
}
for (i=1;i<=h;i++) cout << a[i] << endl;
return 0;
}

C++: #include <cstdio>
#include <utility>
#include <vector>

int main() {
    std::vector<int> v;
    
    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
        v.push_back(i);
    }
    
    int n;
    scanf("%d", &n);
    
    int a, b;
    while (~scanf("%d,%d", &a, &b)) {
        std::swap(v[a - 1], v[b - 1]);
    };
    
    for (const auto& i : v) {
        printf("%d\n", i + 1);
    }
}

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

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