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++: #include<iostream>
#include<cstdio>
using namespace std;

int graph[40][40];
int ans[40];

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

  for(int i = 1; i <= n; i++)
  {
    int a, b;
    scanf("%d,%d", &a, &b);
    graph[a][i] = b;
    graph[b][i] = a;
  }

  for(int i = 1; i <= w; i++)
  {
    int x = i;
    for(int y = 1; y <= n; y++)
    {
      if(graph[x][y])
	x = graph[x][y];
    }
    ans[x] = i;
  }

  for(int i = 1; i <= w; i++)
    cout << ans[i] << endl;
  return 0;
}

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

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

C++: #include <stdio.h>

int main()
{
	int w,n,a,b;
	int ans[30],temp;

	scanf("%d%d",&w,&n);
	for(int i = 0; i < w; i++){
		ans[i] = i+1;
	}

	for(int i = 0; i < n; i++){
		scanf("%d,%d",&a,&b);
		temp = ans[a-1];
		ans[a-1] = ans[b-1];
		ans[b-1] = temp;
	}

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

	return 0;
}

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


#define MAX 30


int in[MAX];

int w , n;

int Left , Right;


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

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

	for (int i = 0; i < n; i++)
	{
		scanf("%d,%d" , &Left , &Right);

		int tmp = in[Left - 1];
		in[Left - 1] = in[Right - 1];
		in[Right - 1] = tmp;
	}

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

	return 0;
}

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

int main() {
int w,n;
cin>>w>>n;
int tate[w+1];
for (int k=0;k<=w;k++){
	tate[k]=k;
}
for (int l=0;l<n;l++){
	int a,b,c;
	char pp;
	cin>>a>>pp>>b;
	c=tate[a];
	tate[a]=tate[b];
	tate[b]=c;
}
for (int ll=1;ll<=w;ll++){
	cout<<tate[ll]<<endl;
}
	return 0;
}

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

int main()
{
	int ary[31];
	int n, w;

	cin >> w >> n;
	for (int i = 1; i <= w; i++)
	{
		ary[i] = i;
	}
	for (int i = 0; i < n; i++)
	{
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(ary[a], ary[b]);
	}
	for (int i = 1; i <= w; i++)
	{
		cout << ary[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
//-------------
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <numeric>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef  long long LL;
typedef  vector<int> VI;
typedef  vector<string> VS;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(x) REP(i,SZ(x))cerr<<i<<x<<"="<<x[i]<<endl;
#define SIZE(x) cout<<sizeof(x)<<endl;
const int MOD = 1000000007;
//-------------
//cout
//-------------
#define COUTL(x) cout<<x<<endl
#define COUT(x) cout<<x
//-------------
//??£?¨??????\
//-------------
#define INTIN(x) int x; cin>>x;
#define INTINTIN(x,y) int x,y; cin>>x>>y;
#define STRIN(x) string x; cin>>x;
int main()
{
	VI amida;
	int w,n;
	cin >> w >> n;
	REP(i,w)
	{
		amida.push_back(i+1);
	}
	REP(i, n)
	{
		string temp;
		cin >> temp;
		int x = temp[0] - 48;
		int y = temp[2] - 48;
		int test;
		test = amida[x-1];
		amida[x - 1] = amida[y - 1];
		amida[y - 1] = test;
	}
	REP(i, w)
	{
		COUTL(amida[i]);
	}
	#ifdef _DEBUG
	while(1);
#endif
	return 0;
}

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

using namespace std;

int main(){
	int w, n;
	int line[30];

	cin >> w;
	cin >> n;

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

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

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

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int w, n;
	cin >> w >> n;
	int s[w];

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

		while(n--){
		int a, b;
		cin >> a >> b;

		int tmp = s[a-1];
		s[a-1] = s[b-1];
		s[b-1] = tmp;
	}

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

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int w,n,i;
	int a[31],b[31],suu[31];
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=1;i<=w;i++) suu[i]=i;
	for(i=1;i<=n;i++){
		scanf("%d,%d",&a[i],&b[i]);
	}
	for(i=1;i<=n;i++) swap(suu[a[i]],suu[b[i]]);
	for(i=1;i<=w;i++) printf("%d\n",suu[i]);
	return 0;
}