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>

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

	for(int t=0; t<n; t++){
		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;
	}

	return 0;
}

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

using namespace std;

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

    vector<int> v(w);
    iota(v.begin(), v.end(), 1);

    int a, b;
    char c;
    for (int i=0; i<n; ++i) {
        cin >> a >> c >> b;
        swap(v[a - 1], v[b - 1]);
    }

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

    return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
int main(){
 
    int w,n,left,right;
    scanf("%d",&w);
    int array[w+1];
    for(int i=0;i<w+1;i++)array[i]=i;
    scanf("%d",&n);
 
    for(int i=0;i<n;i++){
        scanf("%d,%d",&left,&right);
        swap(array[left],array[right]);
    }
 
    for(int i=1;i<=w;i++){
        printf("%d\n",array[i]);
    }
 
    return 0;
}

C++: #include <stdio.h>

void swap(int* a,int* b);

int main(void) {

  int w,n;
  int seq[50];
  int a,b;
  int i,temp;
  
  scanf("%d",&w);

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

  scanf("%d",&n);

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

  for(i=0;i<5;i++) printf("%d\n",seq[i]);
 
  return 0;
}

void swap(int* a,int* b) {
  int temp;

  temp=*a;
  *a=*b;
  *b=temp;
}

C++: #include <stdio.h>

int main(){
	int w,n;
	scanf("%d%d", &w,&n);

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

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

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

C++: #include<bits/stdc++.h>
using namespace std;
inline int nextInt(void){
	int res=0;
	char ch=getchar();
	while(ch>'9'||ch<'0')
		ch=getchar();
	while(ch<='9'&&ch>='0'){
		res=res*10+ch-'0';
		ch=getchar();
	}
	return res;
}
signed main(void){
	int n=nextInt(),m=nextInt();
	int ans[n+1],line[m+1][2];
	for(int i=1;i<=m;i++){
		line[i][0]=nextInt();
		line[i][1]=nextInt();
	}
	for(int i=1,t;i<=n;i++){
		t=i;
		for(int d=1;d<=m;d++){
			if(line[d][0]==t)
				t=line[d][1];
			else if(line[d][1]==t)
				t=line[d][0];
		}
		ans[t]=i;
	}
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
}

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

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

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
int w,n;
cin>>w>>n;
vector<int> number(w);
REP(i, w){
	number[i]=i+1;
}
REP(i,n){
string s,s2;
	getline(cin, s,',');
	getline(cin, s2);
	int a,b;
	a = atoi(s.c_str());
	b = atoi(s2.c_str());
	int t=number[a-1];
	number[a - 1] = number[b-1];
	number[b - 1]=t;
}
REP(i, w)
cout << number[i]<<endl;
}

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

using namespace std;

int main()
{
	int w, n, b, c, p;
	int a[31];

	cin >> w >> n;

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

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

C++: /*AOJ 0011*/

#include<iostream>
#include<vector>

using namespace std;

int main(){
	int w,n;

	cin>>w;
	cin>>n;

	vector<int> a;
	vector<int> b;

	int ans[30];

	for(int i=0;i<n;i++){
		int tmp1,tmp2;
		scanf("%d,%d",&tmp1,&tmp2);
		a.push_back(tmp1-1);
		b.push_back(tmp2-1);
	}
	/*
	for(int i=0;i<n;i++){
		cout<<a[i]<<" "<<b[i]<<endl;
	}
	*/

	for(int i=0;i<w;i++){
		int point = i;

		for(int j=0;j<n;j++){
			if(point==a[j]){
				point = b[j];
			}
			else if(point==b[j]){
				point = a[j];
			}
		}
		ans[point] = i+1;
	}

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

	return 0;
}

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

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

	cin >> w >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> dummy >> b[i];
	}

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

	for (int i = 0; i < n; i++)
		swap(ans[a[i]-1], ans[b[i]-1]);

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

	return 0;
}

C++: #include <cstdio>

int main(){
  int w,n;
  scanf("%d %d",&w,&n);
  int a[w];
  for(int i=0; i<w; i++) a[i]=i+1;
  while(n--){
    int b,c,e;
    scanf("%d,%d",&b,&c);
    e=a[b-1];
    a[b-1]=a[c-1];
    a[c-1]=e;
  }
  for(int i=0; i<w; i++)
    printf("%d\n",a[i]);
}

C++: #include<iostream>
#include<vector>
#include <stdio.h>
int main(){
	int w;
	std::cin>>w;
	std::vector<int> a(w+1);
	for(int i=1;i<=w;i++)a[i]=i;
	int n;
	std::cin>>n;
	while(n>0){
		int b,c;
		scanf("%d,%d",&b,&c);
		//std::cin>>b>>c;
		int d=a[b];
		a[b]=a[c];
		a[c]=d;
		n--;
	}
	for(int i=1;i<=w;i++)std::cout<<a[i]<<std::endl;
	return 0;
}

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

int main(){
	int w, n, a[30], b[30], result[30];
    std::cin >> w >> n;
    for(int i=0; i<n; i++){
        (std::cin >> a[i]).ignore() >> b[i];
        a[i]--;
        b[i]--;
    }
    for(int i=0; i<w; i++)
        result[i] = i;
    for(int i=0; i<n; i++)
        std::swap(result[a[i]], result[b[i]]);
    for(int i=0; i<w; i++)
        std::cout << result[i] + 1 << std::endl;
	return 0;
}

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


int main(){
  int verticals,horizontals,a,b;
  cin >> verticals;
  cin >> horizontals;

  int res[verticals];
  for(int i=0;i<verticals;i++) res[i] = i+1;
  for(int i=0;i<horizontals;i++){
    cin >> a >> b;
    
    int tmp = res[a-1];
    res[a-1] = res[b-1];
    res[b-1] = tmp;
  }
  for(int i=0;i<verticals;i++) cout << res[i] << endl;
}