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 map[30][31];
int w,n;

void search(int s_x,int x,int y)
{
/*	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<w;j++)
		{
			cout << map[j][i] << " " ;
		}
		cout << endl;
	}
	
	getchar();
	system("cls");
*/	
	if(y==n)
	{
		map[x][n]=s_x+1;
		return ;
	}
	
	if(map[x][y]!=100)
		x=map[x][y];
	
	search(s_x,x,y+1);
}

int main()
{
	int a1,b1;
	int i,j;
	char a;
	
	cin >> w ;
	cin >> n ;
	
	for(i=0;i<=n;i++)
		for(j=0;j<w;j++)
			map[j][i]=100;
	
	for(i=0,j=0;i<n;i++,j++)
	{
		cin >> a1 >> a >> b1 ;
		map[a1-1][j]=b1-1;
		map[b1-1][j]=a1-1;
	}
	
/*	for(i=0;i<=n;i++)
	{
		for(j=0;j<w;j++)
		{
			cout << map[j][i] << " " ;
		}
		cout << endl;
	}
	
	getchar();
	system("cls");
*/	
	for(i=0;i<w;i++)
	{
		search(i,i,0);
	}
	
	for(i=0;i<w;i++)
	{
		cout << map[i][n] << endl;
	}
}

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];
	for(int i=1;i<=n;i++)
		ans[i]=i;
	for(int i=1;i<=m;i++)
		swap(ans[nextInt()],ans[nextInt()]);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
}

C++: #include<iostream>

using namespace std;

int main() {
	int i, j, l, num[31], w, n, a=0, b=0, c;
	char kanma;
	
	cin >> w;
	for (i = 1; i <= w; i++) {
		num[i] = i;
	}
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a >> kanma >> b;
		c = num[a];
		num[a] = num[b];
		num[b] = c;
	}
	for (i = 1; i <= w; i++) {
		cout << num[i] << endl;
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define llong long long

int main() {
  int w,n;
  scanf("%d %d", &w, &n);
  int data[w+1];
  REP(i,w+1){
    data[i] = i;
  }
  REP(i,n) {
    int a,b;
    scanf("%d,%d", &a, &b);
    swap(data[a],data[b]);
  }
  FOR(i,1,w+1) {
    printf("%d\n",data[i]);
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int ban[31];
  int a,b;
  int w;
  int n;
  cin >> w >> n;
  for(int i = 1;i <= w;i++){
    ban[i] = i;
  }
  for(int i = 0;i < n;i++){
    scanf("%d,%d",&a,&b);
    swap(ban[a],ban[b]);
  }
  for(int i = 1;i <= w;i++){
    cout << ban[i] << endl;
  }
  return(0);
}

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

using namespace std;

void solve(int w,int n){
  vector<int> v;
  for(int i=0;i<w+1;i++){
    v.push_back(i);
  }
  for(int i=0;i<n;i++){
    int a,b;
    char c;
    cin >> a >>c>> b;
    int temp = v[a];
    v[a] = v[b];
    v[b] = temp;
  }
  for(int i=1;i<w+1;i++){
    cout << v[i] << endl;
  }
}
int main(){
  int w,n;
  cin >> w;
  cin >> n;
  solve(w,n);
  return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;

int main(){
	int w;
	cin>>w;
	vector<int> x(w);
	for(int i=0;i<w;i++)x[i]=i+1;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int a=s[0]-'0';
		int b=s[2]-'0';
		a--;
		b--;
		int tmp=x[a];
		x[a]=x[b];
		x[b]=tmp;
	}
	for(int i=0;i<w;i++)cout<<x[i]<<endl;
	return 0;
}

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

int main() {

	int place[31];
	int w, n;
	cin >> w >> n;
	for(int i = 1; i <= w; i++)
		place[i] = i;
	
	int a, b;
	char c;
	for(int i = 1; i <= n; i++){
		cin >> a >> c >> b;
		
		int temp = place[a];
		place[a] = place[b];
		place[b] = temp;
	}
	
	for(int i = 1; i <= w; i++)
		cout << place[i] << endl;
	
	return 0;
}

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


using namespace std;


int main(){
    
    int w,n,a,b;
    cin >> w >> n;
    vector<int> ans;
    for(int i=0;i<=w;i++){
        ans.push_back(i);
    }

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

C++: #include <iostream>

using namespace std;

int main() {
    int w, n, a, b;
    char com;
    int lot[31];
    
    for(int i=0; i<30; i++){
        lot[i] = i;
    }
    
    cin >> w >> n;
    for(int i=0; i<n; i++){
        cin >> a >> com >> b;
        swap(lot[a], lot[b]);
    }
    for(int i=1; i<=w; i++){
        cout << lot[i] << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a,s,d,f,g[31],h,i,j;
	scanf("%d",&a);
	scanf("%d",&s);
	for(i=1;i<=a;i++){
		g[i]=i;
	}
	for(i=1;i<=s;i++){
		scanf("%d,%d",&d,&f);
		h=g[d];
		g[d]=g[f];
		g[f]=h;
	}
	for(i=1;i<=a;i++){
		printf("%d\n",g[i]);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int w,n,a,b,num[30];
	char ch;
	cin >> w >> n;
	for(int i=0;i<w;i++){
		num[i] = i+1;
	}
	for(int i=0;i<n;i++){
		cin >> a >> ch >> b;
		swap(num[a-1],num[b-1]);
	}
	for(int i=0;i<w;i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include<algorithm>
#include<iostream>
using namespace std;
int main(){
	int w,n;
	cin>>w>>n;
	int a[w],b[w];
	for(int i=0;i<n;i++){
		swap(a[n],b[n]);
	}
	for(int j=0;j<w;j++){
		cout<<a[j]<<endl<<b[j]<<endl;
	}
}

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

struct THorizonalLine
{
	int Left;
	int Right;
};

int main()
{
	int w;
	cin >> w;
	int n;
	cin >> n;
	vector<int> StartingPoint(w);
	for(int i = 0; i < w; i++){
		StartingPoint[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		THorizonalLine HorizonalLine;
		scanf("%d,%d",&HorizonalLine.Left,&HorizonalLine.Right);
		swap(StartingPoint[HorizonalLine.Left-1], StartingPoint[HorizonalLine.Right-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}

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

using namespace std;

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

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

	while (n--)
	{
		int a, b;
		scanf("%d,%d", &a, &b);

		swap(s[a], s[b]);
	}

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

	return 0;
}

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

int main() {
	int w, n, a, b;

	cin >> w >> n;
	auto hlines = vector<int>(w);
	for (int i = 0; i < w; ++i) {
		hlines.at(i) = i + 1;
	}

	for (int i = 0; i < n; ++i) {
		cin >> a;
		cin.ignore();
		cin >> b;
		--a, --b;
		swap(hlines.at(a), hlines.at(b));
	}
	for (int const x : hlines) {
		cout << x << endl;
	}
	return 0;
}