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 <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)

int main(){
    int w, n;
    cin >> w >> n;
    vector<int> num(w, 0);
    int it = 1;
    for(int& k : num) k = it++;
    rep(i, n){
        string a;
        cin >> a;
        swap(num[a[0] - '1'], num[a[2] - '1']);
    }
    for(int k : num)
      cout << k << endl;
    return 0;
}

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

using namespace std;

double dist(double x1, double y1, double x2, double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main(){
	int w, n;

	char bar[10];
	vector<int> a(31);
	const char delim = ',';
	int left, right;

	for(int i = 1; i <= 30; i++){
		a[i] = i;
	}

	cin >> w >> n;

	while(n--){
		cin >> bar;
		left = atoi(strtok(bar, &delim));
		right = atoi(strtok(NULL, &delim));
		swap(a[left], a[right]);
	}

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

	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int n,m,dumy=0,a,b;
	cin>>n>>m;
	int x[n];
	for(int i=0;i<n;i++)
	x[i]=i+1;
	for(int i=0;i<m;i++){
		scanf("%d,%d",&a,&b);
		swap(x[a-1],x[b-1]);
	}
	for(int i=0;i<n;i++)
	cout<<x[i]<<endl;
	return 0;
}

C++: /*
NOTE :
*min_element(.begin(),.end())
*max_element(.begin(),.end())
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define MAX 100
#define INF 1<<20
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;
/////

/////
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  int w; scanf("%d",&w);
  int n; scanf("%d",&n);
  vector<int> T(w);
  REP(i,w) T[i] = i;
  REP(i,n)
  {
    int a, b;
    scanf("%d,%d",&a,&b);
    swap(T[a-1],T[b-1]);
  }
  REP(i,w) cout << T[i]+1 << endl;
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int ans[30];
int main() {
	int w, n; cin >> w >> n;
	vector<P>vec;
	rep(i, n) {
		int a, b; scanf("%d,%d", &a, &b);
		vec.push_back(P(a, b));
	}
	for (int i = 1; i <= w; i++) {
		int pos = i;
		rep(j, vec.size()) {
			if (vec[j].first == pos)pos = vec[j].second;
			else if (vec[j].second == pos)pos = vec[j].first;
		}
		ans[--pos] = i;
	}
	rep(i, w) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

int main(){
	int n,w,ans[31],from,to;
	char com;
	cin>>w>>n;
	for(int i=1;i<=w;i++){
		ans[i]=i;
	}
	for(int i=0;i<n;i++){
		cin>>from>>com>>to;
		int tmp=ans[from];
		ans[from]=ans[to];
		ans[to]=tmp;
	}
	for(int i=1;i<=w;i++){
		cout<<ans[i]<<endl;
	}
    return 0;
}

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

using namespace std;

int main() {
  int W;
  int N;
  int num[30];

  
  cin >> W;
  cin >> N;
  for (int i = 0; i < W; i++) {
    num[i] = i+1;
  }
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a;
    cin.ignore();
    cin >> b;
    swap(num[a-1], num[b-1]);
  }
  for (int i = 0; i < W; i++) {
    cout << num[i] << endl;
  }
  return 0;
}

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

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

C++: #include <iostream>

using namespace std;

int main(){

	int a,b,c;
	int Buffer;
	int VirticalLine[30];
	int HorizonLine[30][2];
	char BB;
			
	
	
	cin>>a>>b;
	
	for(c=0;c<a;c++){
	VirticalLine[c] = c+1;
	}
	for(c=0;c<b;c++){
	cin>>HorizonLine[c][0]>>BB>>HorizonLine[c][1];
	}
	for(c=0;c<b;c++){

		Buffer = VirticalLine[HorizonLine[c][1]-1];
		VirticalLine[HorizonLine[c][1]-1] = VirticalLine[HorizonLine[c][0]-1];
		VirticalLine[HorizonLine[c][0]-1] = Buffer;

	}

	for(c=0;c<a;c++)
	{
	cout<<VirticalLine[c]<<endl;
	}

return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;

constexpr int IMAX = ((1<<30)-1)*2+1 ;
constexpr int INF = 100000000;
double EPS = 1e-10 ;

int main(){
  char c;
  int w,n,a,b,num,ans[5];
  bool flag = true;
  cin >> w >> n;
  vi v(w,0),va,vb ;
  rep(i,n){
    cin >> a >> c >> b ;
    va.pb(a),vb.pb(b) ;
  }

  rep(i,w){
    num = i+1 ;
    rep(j,n){
      if(num == va[j]){
        num = vb[j];
      }
      else if(num == vb[j]){
        num = va[j];
      }
    }
    ans[num-1] = i+1;
  }
  repa(tmp,ans){
    cout << tmp << endl;
  }
  return 0;
}

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

C++: #include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	int n,m,a[31],b[31];

	cin >> n >> m;

	char o;

	for (int i = 0; i < m; i++)
	{
		cin >> a[i] >> o >> b[i];
	}

	int p[31];

	for (int j = 1; j < n + 1; j++)
	{
		p[j] = j;
	}

	for (int i = 0; i < m; i++)
	{
		int ha = 0,hb = 0;

		ha = p[b[i]];
		hb = p[a[i]];

		p[a[i]] = 0;
		p[a[i]] = ha;

		p[b[i]] = 0;
		p[b[i]] = hb;
	}

	for (int j = 1; j < n + 1; j++)
	{
		cout << p[j] << endl;
	}
}