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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	int w, n, a, b;
	vi v;
	cin >> w >> n;
	FOR(i, 1, w+1){
		v.push_back(i);
	}
	REP(i,n){
		scanf("%d,%d",&a, &b);
		swap(v[a-1], v[b-1]);
	}
	REP(i, w){
		cout << v[i] << "\n";
	}
}

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

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

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;
	std::cin >> w >> n;
	rep(i, MAX)
		num[i] = i + 1;		
	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;
}

C++: #include<iostream>

using namespace std;
int data[40];
int main(){

	for(int i=0;i<40;i++)data[i]=i;
	int w;
	int n;
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		char tmp[4];
		cin>>tmp;
		int a=tmp[0]-'0';
		int b=tmp[2]-'0';
		int t=data[a];
		data[a]=data[b];
		data[b]=t;
	}
	
	for(int i=1;i<=w;i++)cout<<data[i]<<endl;
}

C++: #include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
#define FOR(i, s, e) for(int i = s; i < e; ++i)
void getValues(string& s, int& a, int & b)
{
	string::size_type p = s.find(',');
	string sa = s.substr(0, p);
	string sb = s.substr(p + 1);
	a = atoi(sa.c_str());
	b = atoi(sb.c_str());
}

int main()
{
	int w, n, a, b;
	cin >> w >> n;
	int W[31] = {};
	FOR(i, 1, w + 1) W[i] = i;
	string line;
	while (n--){
		cin >> line;
		getValues(line, a, b);
		swap(W[a], W[b]);
	}
	FOR(i, 1, w + 1) cout << W[i] << "\n";
	return 0;
}

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

int main()
{
  int width,number;
  cin >> width >> number;
  int change[number][2];
  string str;
  for(int i=0; i<number; i++){
    scanf("%d,%d",&change[i][0],&change[i][1]);
  }
  int bou[width+1];
  for(int i=0; i<width+1; i++){
    bou[i] = i;
  }
  int temp;
  for(int i=0; i<number; i++){
    temp = bou[change[i][0]];
    bou[change[i][0]] = bou[change[i][1]];
    bou[change[i][1]] = temp;
  }

  for(int i=1; i<width+1; i++){
    cout << bou[i] << endl;
  }
  return 0;
}

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

#define swap(a,b) a^=b^=a^=b

using namespace std;

int main(){
    
    int w,n,a,b;
    cin >> w >> n;
    int *ans = new int(w+1);


    for(int i=0;i<=w;i++){
        ans[i]=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;
    }
    delete ans;
    
}

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

int w, n, l[31];

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

	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS 1

#include <cstdio>

using namespace std;

int main()
{
	int W, N, A[31], B[31], C[31];

	scanf("%d", &W);
	scanf("%d", &N);

	for (int i = 1; i <= N; i++)
	{
		scanf("%d,%d", &(A[i]), &(B[i]));
	}

	for (int i = 1; i <= W; i++)
	{
		int t = i;

		for (int j = 1; j <= N; j++)
		{
			if (A[j] == t)
			{
				t = B[j];
			}
			else if (B[j] == t)
			{
				t = A[j];
			}
		}

		C[t] = i;
	}

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

	return 0;
}

C++: // あみだくじ。

#include <iostream>
#include <cstdio>
using namespace std;

int main(void) {
    int w, n;
    int* vertical;
    int a, b, tmp;
    
    cin >> w;
    vertical = new int[w + 1];
    for(int i = 0; i <= w; ++i) {
        vertical[i] = i;
    }
    cin >> n;
// scanfの""内に','を入れることで入力の仕方をa,bにすることが出来る。abはエラー
    for(int i = 0; i < n; ++i) {
        scanf("%d,%d", &a, &b);
        tmp         = vertical[a];
        vertical[a] = vertical[b];
        vertical[b] = tmp;
    }
    for(int i = 1; i <= w; ++i) {
        cout << vertical[i] << endl;
    }
}

C++: #include<iostream>
using namespace std;
int n;
int a[1000000];
int sum[1000000];
int main(int argc, char const *argv[])
{

	int tc[30];
	cin>>tc[30];
	int w,v;
	for (int i = 0; i < 30; ++i) tc[i] = i+1;
		for (int i = 0; i < v; ++i)
		{
			int a,b;
			cin>>a>>b;
			int c=tc[a-1];
			tc[a-1]=tc[b-1];
			tc[b-1];

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

C++: //============================================================================
// Name        : desk.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<stdio.h>
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
int w,n;
cin>>w>>n; //w????¨???????n????????\?????????????????°
int N[w]; //???????????°
for(int i=0;i<w;i++){
	N[i]=i+1; //?¨??????°?????\???????§?
}
for(int i=0;i<n;i++){
	int a,b;
	char c;
	cin>>a>>c>>b; //char???,?????\????????¨
	swap(N[a-1],N[b-1]); //swap??§??´??\??\?????????
}
for(int i=0;i<w;i++){
	cout<<N[i]<<endl; //?????¨?????????
}
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>
#include <cmath>

int main(void)
{
  int w, n;

  std::cin >> w >> n;

  std::vector<int> base;
  for (int i = 0; i < w; i++) {
    base.push_back(i + 1);
  }

  for (int i = 0; i < n; i++) {
    int a, b;
    scanf_s("%d,%d", &a, &b);
    std::swap(base[a - 1], base[b - 1]);
  }

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

  return 0;
}

C++: // 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int w;
	cin >> w;
	vector<int> A;
	for(int i = 1; i <= w; i++)A.push_back(i);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		string a, b;
		for(int j = 0; j < (int)s.size(); j++){
			if(s[j] == ','){
				a = s.substr(0, j);
				b = s.substr(j + 1);
				break;
			}
		}
		int x = stoi(a), y = stoi(b);
		x--;
		y--;
		swap(A[x], A[y]);
	}
	for(int i = 0; i < w; i++)cout << A[i] << '\n';
	return 0;
}
// Write Here