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 <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

int a[50],b[50];

int main(){

	int w,h;
	cin>>w>>h;
	for (int i = 0; i < h; i++)
	{
		char c;
		cin>>a[i]>>c>>b[i];
		a[i]--; b[i]--;
	}

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

	for (int i = 0; i < h; i++)
	{
		swap(v[a[i]],v[b[i]]);
	}

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


	return 0;
}

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

using namespace std;

void change(int *, int *);

int main(void){
	int w,n;
	int p[31];
	int a, b;
	cin >> w;
	cin >> n;
	
	for(int i = 1; i <= w; i++){
		p[i] = i;
	}
	
	for(int j = 0; j < n; j++){
		scanf("%d,%d", &a, &b);
		change(&p[a], &p[b]);
		
	}
	for(int i = 1; i <= w; i++){
		cout << p[i] << endl;
	}
	return 0;
}

void change(int *x, int *y){
	int type = *x;
	*x = *y;
	*y = type;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);


int main(void){
	int w, n;
	cin >> w >> n;
	vector<int> v;
	rep(i, w){
		v.pb(i+1);
	}
	rep(i, n){
		int a,b;
		char c;
		cin >> a >> c >> b;
		swap(v[a-1], v[b-1]);
	}
	rep(i, v.size()){
		FIN(v[i]);
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include <iostream>
using namespace std;
int main(){
    int w,n;//1~wまでの番号を用意、ｎ回の操作
    int a[30]={-1};
    int j,k;
    int temp,temp1;
    
    while(cin >> w){
        
        if(w==0)break;

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

        cin >> n;
    //コンマの入力,temp使用        

        for(int i=0;i<n;i++){

            cin >> j >> temp >> k;
            
            temp1=a[j-1];
            a[j-1]=a[k-1];
            a[k-1]=temp1;

        }

        for(int i=0;i<w-1;i++){
            cout << a[i] << " ";
        }
        cout << a[w-1] << 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 <iostream>
#include <cstdio>
#include <stdio.h>
using namespace std;
int main(){
	int w,n;
	int a,b,c;
	cin>>w;
	cin>>n;
	int num[30] = {0};
	for(int i=-0;i<w;i++){
		num[i] = i+1;
	}
	for(int j=0;j<n;j++){
		scanf("%d,%d",&a,&b);
		c = num[a-1];
		num[a-1] = num[b-1];
		num[b-1] = c;
	}
	for(int k=0;k<w;k++){
		printf("%d\n",num[k]);
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

struct stick {
  int a;
  int b;
};

int w, n;

int main() {
  int i;
  cin >> w;
  cin >> n;
  stick s[n];
  char split;

  for(i = 0; i < n; i++)
    cin >> s[i].a >> split >> s[i].b;

  for(i = 1; i <= w; i++) {
    int start = i;
    int j;

    for(j = n - 1; 0 <= j; j--) {
      int flag = start;
      if(start == s[j].a)
	flag = s[j].b;
      if(start == s[j].b)
	flag = s[j].a;
      start = flag;
    }
    cout << start << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;

double dist(double x1, double y1, double x2, double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main(){
	int w, n;

	char bar[10];
	vector<int> a(31);
	const char delim = ',';
	int left, right;

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

	cin >> w >> n;

	while(n--){
		cin >> bar;
		left = atoi(strtok(bar, &delim));
		right = atoi(strtok(NULL, &delim));
		swap(a[left], a[right]);
	}

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

	return 0;
}

C++: //43
#include<iostream>

using namespace std;

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

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

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

#define FOR(i, a) for(int i=0;i<(int)a;++i)
typedef long long ll;
typedef long double ld;
using namespace std;

void solver() {
    int w, n;
    vector<int> a, b;
    vector<pair<int, int>> ans;
    cin >> w;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int ta, tb;
        scanf("%d,%d", &ta, &tb);
        a.push_back(ta);
        b.push_back(tb);
    }

    FOR(i, w) {
        auto p = i + 1;
        FOR(j, n) {
            if (p == a[j]) {
                p = b[j];
            } else if (p == b[j]) {
                p = a[j];
            }
        }
        ans.push_back({p, i + 1});
    }
    sort(ans.begin(), ans.end());

    FOR(i, w) cout << ans[i].second << endl;
}

int main() {
    solver();
    return 0;
}

C++: #include <bits/stdc++.h>

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;



int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int w = 0, n = 0;
	std::cin >> w >> n;

	std::vector<int> A(w + 1);
	std::iota(A.begin(), A.end(), 0);

	for (int i = 0; i < n; i++) {

		int a = 0, b = 0;
		std::string temp;
		std::cin >> temp;
		a = std::stoi(temp.substr(0, temp.find(',', 0)));
		b = std::stoi(temp.substr(temp.find(',', 0) + 1, temp.length()));
		std::swap(A[a], A[b]);

	}

	for (int i = 1; i <= w; i++) {
		std::cout << A[i] << std::endl;
	}

}

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

using namespace std;

void input();
void calc();
void output();

int main(void)
{

	input();
	calc();
	output();
}


int n,m;
std::vector<int> line;

void set_line()
{
	for (int i = 0; i < n; i++)
	{
		line.push_back(i + 1);
	}
}

void input()
{
	cin >> n >> m;
	set_line();

}

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

}

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

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>

#define MAX 30
#define rep(i, a) for(int i = 0; i < (a); ++i)
#define rept(i, a, b) for(int i = (a); i <= (b); ++i)

int main(){
	int w, n;
	int num[MAX];
	int a, b;
	rep(i, n)
		num[i] = i + 1;		
	std::cin >> w >> n;
	rep(i, n){
		scanf("%d,%d", &a, &b);
		std::swap(num[a - 1], num[b - 1]);
	}
	rep(i, w)
		std::cout << num[i] << std::endl;
	return 0;
}