Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

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

class Amidakuji {
public:
private:
	int w;	// 縦線の本数
	int n;	// 横棒の本数
	int an_list[30];
	int bn_list[30];
public:
	void inputWN(int ww, int nn);
	void inputList();
	int* calc();
private:
	int a(int n);
	int b(int n);
};

int main() {
	Amidakuji amidakuji;
	int w, n;
	cin >> w >> n;
	int* status = new int[w];
	
	amidakuji.inputWN(w, n);
	amidakuji.inputList();
	
	status = amidakuji.calc();
	
	for(int i = 0; i < w; ++i) {
		cout << status[i] << endl;
	}
}


void Amidakuji::inputWN(int ww, int nn) {
	w = ww;
	n = nn;
}

void Amidakuji::inputList() {
	int an, bn;
	for(int i = 0; i < n; ++i) {
		scanf("%d,%d", &an, &bn);
		
		an_list[i] = an;
		bn_list[i] = bn;
	}
}

int* Amidakuji::calc() {
	int* status = new int[w];
	for(int i = 0; i < w; ++i) {
		status[i] = i + 1;
	}
	
	for(int i = 0; i < n; ++i) {
		int an = a(i)-1;
		int bn = b(i)-1;
		
		swap(status[an], status[bn]);
	}
	
	return status;
}

int Amidakuji::a(int n) {
	return an_list[n];
}

int Amidakuji::b(int n) {
	return bn_list[n];
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>
#include <sstream>

using namespace std;


bool solve(){
	int w, n;
	cin>> w>> n;
	vector<int> W(w,0);
	for(int i=0;i<w;i++){
		W[i]=i+1;
	}
	
	int a, b;
	char c;
	for(int i=0;i<n;i++){
		cin>> a>> c>> b;
		swap(W[a-1],W[b-1]);
	}
	
	for(int i=0;i<w;i++){
		cout<< W[i]<< endl;
	}
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(5);
	solve();

	return 0;
}

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	int w,n;
	scanf("%d %d",&w,&n);
	vector<int> table;
	for(int x=0;x<=w;x++){
		table.push_back(x);
	}
	for(int x=0;x<n;++x){
		int i,j;
		scanf("%d, %d",&i,&j);
		swap(table[i],table[j]);
	}
	for(int x=1;x<=w;++x){
		cout<<table[x]<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <utility>
using namespace std;
const int MAX_W = 30;
int main()
{
    int w,n;
	int num[MAX_W+1]={};
	char c;
	cin>>w>>n;
	for(int i=0;i<w;i++){
		num[i]=i+1;
	}
	int a,b;
	for(int i=0;i<n;i++){
		cin>>a>>c>>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<string>
#include<vector>
#include<algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define ll long long int

#define rep(p,q) for(int i = p; i < q;i++)


//11

int main(void) {
	int w, n;
	cin >> w >> n;
	int line[30];
	rep(0, 30) line[i] = i+1;
	rep(0, n) {
		int a, b;
		string comma;
		cin >> a >> comma;
		b = stoi(comma.substr(1));
		int swap = line[a - 1];
		line[a - 1] = line[b - 1];
		line[b - 1] = swap;
	}
	rep(0, w) {
		cout << line[i] << endl;
	}
}

C++: #include <stdio.h>

int main(){

	int a[2][30] = {}, w = 0, y = 0, i, t[30] = {};

	scanf("%d%d", &w, &y);

	for (i = 0; i < y; i++){
		scanf("%d,%d", &a[0][i], &a[1][i]);
	}

	for (i = 0; i < w; i++){
		t[i] = i+1;
	}
	for (i = 0; i < y; i++){
		w = t[a[0][i]-1];
		t[a[0][i]-1] = t[a[1][i]-1];
		t[a[1][i]-1] = w;

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

	return 0;
}

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

using namespace std;

void vswap(int, int);
vector<int> a;

int main(){
	int w, n; cin >> w >> n;
	for(int i = 1; i <= w; i++) a.push_back(i);
	for(int i = 0; i < n; i++){
		int x, y;
		scanf("%d,%d", &x, &y);
		vswap(x - 1, y - 1);
	}
	for(int i = 0; i < a.size(); i++) cout << a[i] << endl;
	return 0;
}

void vswap(int x, int y){
	int tmp;
	tmp = a[y];
	a[y] = a[x];
	a[x] = tmp;
	return;	
}

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