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<fstream>
using namespace std;

int main()
{
	int w,wl[30],n,a,b,c;
	char ch;
	for(int i=0;i<30;i++){
		wl[i]=i;
	}
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		cin>>ch;
		cin>>b;
		c=wl[a];
		wl[a]=wl[b];
		wl[b]=c;
	}
	for(int i=0;i<w;i++){
		cout<<wl[i+1]<<endl;
	}
}

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

int main() {
  int w,n;
  cin >> w >> n;
  int array[w];
  for (int i = 0; i < w; i++) array[i] = i+1;
  for (int i = 0; i < n; i++) {
    int a,b,tmp;
    char c;
    cin >> a >> c >> b;
    tmp = array[a-1];
    array[a-1] = array[b-1];
    array[b-1] = tmp;
  }
  for (int i = 0; i < w; i++) cout << array[i] << endl;
  return 0;
}

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

int main() {
	int w, n,array[30],right,left;
	scanf("%d%d", &w, &n);
	for (int i = 1; i < w+1; i++) {
		array[i] = i;
	}
	for (int j = 0; j < n; j++) {
		scanf("%d,%d", &right, &left);
		swap(array[right], array[left]);
	}

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

	return 0;
}

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

int main()
{
    int n,w;
    int a,b;
    int yoko_1[100],yoko_2[100];
    int ans[100];
    
    cin>>w>>n;
    
    for (int i=0; i<n; i++) {
        cin>>a>>b;
        yoko_1[i]=a;
        yoko_2[i]=b;
    }
    
    int i=0,yoko=1,count=1;
    
    while (1) {
        if (yoko_1[i] == yoko) {
            yoko = yoko_2[i];
            i++;
        }
        else if(yoko_2[i] == yoko){
            yoko = yoko_1[i];
            i++;
        }
        else{
            i++;
        }
        if (w==i) {
            ans[yoko-1]=count;
            i=0;
            count++;
            yoko=count;
        }
        if(count>w){
            break;
        }
    }
    for (int i=0; i<w; i++) {
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

int main()
{
	int w, n;
	vector<pair<int, int> > v;
	cin >> w >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		int index = s.find(',',0);
		int a = stoi(s.substr(0, index).c_str());
		int b = stoi(s.substr(index + 1).c_str());
		v.push_back(make_pair(a, b));
	}
	int numbers[40];
	for (int i = 0; i < w; i++)numbers[i] = i + 1;
	for (int i = 0; i < v.size(); i++)
	{
		int tmp = numbers[v[i].first - 1];
		numbers[v[i].first - 1] = numbers[v[i].second - 1];
		numbers[v[i].second - 1] = tmp;
	}
	for (int i = 0; i < w; i++)cout << numbers[i] << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(void){
	int w,n;
	char comma;
	cin>>w;
	cin>>n;
	int ans[30];
	for(int i=1;i<=w;i++){
		ans[i]=i;
	}
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>comma>>b;
		int tmp=ans[a];
		ans[a]=ans[b];
		ans[b]=tmp;
	}
	for(int i=1;i<=w;i++){
		cout<<ans[i]<<endl;
	}
}

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

using namespace std;

int main()
{
	int w, n, t, a, b, i;
	char c;
	cin >> w;
	vector<int> state(w);
	for (i = 1; i <= w; i++) state[i-1] = i;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a >> c >> b;
		t = state[a-1];
		state[a-1] = state[b-1];
		state[b-1] = t;
	}
	for (i = 0; i < w; i++) cout << state[i] << endl;
	return 0;
}

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

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

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

C++: #include<iostream>
int main(){int t[31],w=1,n,a,b,c;for(;w<31;)t[w]=w++;for(std::cin>>w>>n;n--;){(std::cin>>a).ignore(1)>>b;c=t[a];t[a]=t[b];t[b]=c;}for(n=1;n<w+1;)std::cout<<t[n++]<<'\n';}

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

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

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
void swap(int &a, int &b){
	int c=a;
	a=b;
	b=c;
}
vector<int> v;

int main(){
	int w, n;
	cin >> w >> n;
	int a[n], b[n];
	string s;
	for(int i=0; i<n; i++){
		cin >> s;
		a[i] = stoi(s);
		while(1){
			if(s[0]!=',') s.erase(s.begin(), s.begin()+1);
			else{
				s.erase(s.begin(), s.begin()+1);
				break;
			}
		}
		b[i] = stoi(s);
	}

	v.resize(w);
	for(int i=0; i<v.size(); i++) v[i]=i+1;
	for(int i=0; i<n; i++){
		swap(v[a[i]-1], v[b[i]-1]);
	}

	for(int i=0; i<n; i++) cout << v[i] << endl;

	return 0;
}

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

using namespace std;

int main(void){
  int x,y,a,b,n[31];
  char s;

  cin >> y >> x;
  for(int i=1; i<=y; i++)n[i]=i;

  for(int i=0; i<x; i++){
    cin >> a >> s >> b;
    swap(n[a],n[b]);
  }
  for(int i=1; i<=y; i++)cout << n[i] << endl;

  return 0;
}

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

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

using namespace std;
void lots(int len,int a,int b,int array[]){
    int buffer[5];
    for(int i = 0;i < len; i++){
        if(i == a-1){
            buffer[i] = array[b-1];
        }
        else if(i == b-1){
            buffer[i] = array[a-1];
        }
        else{
            buffer[i] = array[i];
        }
    }
    for(int i = 0; i < len; i++){
        array[i] = buffer[i];
    }

}

int main(){
    int len,duration,a,b;
    cin >> len;
    cin >> duration;
    int array[len];
    for(int i = 0; i < len; i++){
        array[i] = i+1;
    }
    for(int i = 0; i < duration; i++){
        scanf("%d,%d",&a,&b);
        lots(len,a,b,array);
    }
    for(int i = 0; i < len; i++){
        cout << array[i] << endl;
    }
}

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

int main(){
  vector<int> a;
  int w,n,s1,s2;
  char c;
  cin >> w >> n;
  for(int i=1;i<=w;i++)a.push_back(i);
  for(int i=0;i<n;i++){
	cin >> s1 >> c >> s2;
	swap(a[s1-1],a[s2-1]);
  }
  for(auto i:a)cout << i << endl;
  return 0;
}

C++: #include<stdio.h>

int main()
{
    int a,b,c,d;
    int x[30],y,z[30];
    scanf("%d%d",&a,&b);
    for(int i = 0; i < a; i++)
    {
        x[i]=i+1;
    }
    for(int i = 0; i < b; i++)
    {
        scanf("%d,%d",&c,&d);
        y = x[c-1];
        x[c-1] = x[d-1];
        x[d-1] = y;
    }
    for(int i = 0; i < a; i++)
    {
        printf("%d\n",x[i]);
    }
    return 0;
}