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 <utility>
#include <vector>

using namespace std;

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

	vector<int> s(w + 1);
	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<stdio.h>

int main(){
int tate,yoko,bou[30][2],j,x,kekka[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30},i=0;
scanf("%d %d",&tate,&yoko);
for(j=0;j<yoko;j++){
scanf("%d %d",&bou[j][1],&bou[j][2]);
}
for(i=1;i<tate+1;i++){
x=i;
for(j=0;j<yoko;j++){
if(bou[j][1]==x){
x=bou[j][2];
}
else if(bou[j][2]==x){
x=bou[j][1];
}
}
kekka[x-1]=i;
}
for(j=0;j<tate;j++){
printf("%d\n",kekka[j]);
}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  char d[2];
  cin >> n >> m;
  int a[n],b,c;
  for(int i = 0;i < n;i++) a[i] = i+1;
  for(int i = 0;i < m;i++){
    cin >> b >> d[0] >> c;
    swap(a[b-1],a[c-1]);
  }
  for(int i = 0;i < n;i++)cout << a[i] << endl;
  return 0;
}

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

using namespace std;

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

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

	delete[] num;
	return 0;
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	int N=in();
	vector<int> V(N);
	iota(ALL(V),1);
	int Q=in();
	REP(i,Q){
		int a,b;
		scanf("%d,%d",&a,&b);
		swap(V[a-1],V[b-1]);
	}
	for(auto& x:V){
		out(x);
	}

	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 << " ";
    cout << endl;
}

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

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

class Amida{
public:
	void shokika(int a[],int b);
	void irekae(int bou[], int a, int b);
	void show(int bou[], int a);
};

void Amida::shokika(int a[],int b){
	for (int i = 0; i < b; i++){
		a[i] = i+1;
	}
}

void Amida::irekae(int bou[], int a, int b){
	int work;
	work = bou[a-1];
	bou[a-1] = bou[b-1];
	bou[b-1] = work;
}

void Amida::show(int bou[], int a){
	for (int i = 0; i < a; i++){
		cout << bou[i] << endl;
	}
}

int main(){
	int tate, yoko, *tatebou;
	Amida ami;
	cin >> tate >> yoko;

	tatebou = new int[tate];
	ami.shokika(tatebou, tate);

	int a, b;
	for (int i = 0; i < yoko; i++){
		scanf("%d,%d", &a, &b);
		ami.irekae(tatebou, a, b);
	}

	ami.show(tatebou,tate);

	return 0;
}

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

using namespace std;

int w;//縦本の総本数
int n;//横棒の数
int D[31];//あみだの並び順


queue<pair<int,int> > que;
int a,b;
int temp;

int main(){
  scanf("%d %d",&w,&n);
  for(int i = 1;i <= w;i++){
    D[i] = i;
  }//あみだを初期化
  for(int i = 0;i < n;i++){
    scanf("%d,%d",&a,&b);
    que.push(pair<int,int>(a,b));
  }
  for(int i = 0;i <n;i++){
    a =que.front().first;
    b =que.front().second;
    temp = D[b];
    D[b] = D[a];
    D[a] = temp;
    que.pop();
  }
  for(int i = 1;i <=w;i++){
    printf("%d\n",D[i]);
  }

}

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

int main()
{
 int x[30];
 int w, n;
 
 cin >> w >> n;
 for(int i=0; i<w; i++) x[i] = i+1;

 int a, b;
 for(int i=0; i<n; i++){
  cin  >> a >> b;
  int tmp = x[a];
  x[a] = x[b];
  x[b] = tmp;
 }

 for(int i=0; i<w; i++){
  cout << x[i];
  if(i == w-1) break;
  cout << '\n';
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n,m;
  cin>>n>>m;
  int w[30];
  rep(i,n)w[i] = i + 1;
  while(m--){
    int a,b;
    scanf("%d,%d",&a,&b);
    swap(w[--a],w[--b]);
  }
  rep(i,n)cout<<w[i]<<endl;
}

C++: import java.util.Scanner;
public class Main{
	private static void change(int data[],int f,int s){
		int temp = data[f-1];
		data[f-1] = data[s-1];
		data[s-1] = temp;
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int n = scan.nextInt();
		int[] data = new int[w];
		for(int i=0;i<w;i++){
			data[i]=i+1;
		}
		int first =0;
		int second =0;
		scan.useDelimiter(",");
		for(int i=0;i<n;i++){
			first = scan.nextInt();
			second = scan.nextInt();
			change(data,first,second);
		}
		for(int i=0;i<=n;i++)
			System.out.println(data[i]);
	}

}