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 <cstdio>
#include<set>
using namespace std;
set<string> lst;

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

C++: #include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

pair<int, int> p;
int a[31];

int main()
{
	int w, n, r;
	cin >> w >> n;
	for (int i = 1; i < w + 1; i++)
		a[i] = i;
	for (int i = 0; i < n; i++)
	{
		scanf("%d,%d", &p.first, &p.second);
		r = a[p.first];
		a[p.first] = a[p.second];
		a[p.second] = r;
	}
	for (int i = 1; i < w + 1; i++)
	{
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;

const int MOD=1000000007;
const int INF=1000000009;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



signed main(){
  int w,n;
  cin>>w>>n;
  int a[33];
  rep(i,w)a[i]=i;
  rep(i,n){
    int x,y;
    char e;
    cin>>x>>e>>y;
    x--;y--;
    swap(a[x],a[y]);
  }
  rep(i,w){
    cout<<a[i]+1<<endl;
  }

  return 0;
}

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

int main(void)
{
	int w, n, l, r;
	char sep;

	cin >> w >> n;

	vector<int> a;
	for (int i = 0; i < w; i++) a.push_back(i+1);

	for (int i = 0; i < n; i++) {
		cin >> l >> sep >> r;
		swap(a[l-1], a[r-1]);
	}

	for (int i = 0; i < w; i++)
		cout << a[i] << endl;

	return 0;
}

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 <string>
#include <stack>
using namespace std;


int main(){
	int w;
	int n;
	int a[30];
	int b[30];
	int c[30];
	cin >> w;
	cin >> n;
	int x;
	int y;
	int z;
	for (int i = 1; i <= w; i++){
		c[i - 1] = i;
	}
	for (int i = 0; i < n; i++){
		char t;
		cin >> a[i] >> t >> b[i];

		x = a[i];
		y = b[i];
		z = c[x - 1];
		c[x - 1] = c[y - 1];
		c[y - 1] = z;
	}
	for (int i = 0; i < w; i++){
		cout << c[i] << endl;
	}
	return 0;
}

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

int main()
{
    vector<int> bar;
    int n, w;
    char sp;
    int a[2];
    cin >> w;
    for(int c =1; c <= w; c++)
        bar.push_back(c);
    cin >> n;
    for(int c =0; c < n; c++)
    {
        cin >> a[0] >> sp  >> a[1];
        swap(bar[a[0] -1],bar[a[1] -1]);
    }
    for(int c=0; c < w; c++)
        cout << bar[c] << endl;
    return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#define INF 100000000
using namespace std;

int main(){
  int w,n;
  while(cin >> w >> n){
    int amida[31][31][31];
    for(int i=0; i<31; i++)
    for(int j=0; j<31; j++)
    for(int k=0; k<31; k++)
      amida[i][j][k] = 0;

    for(int i = 1 ; i <= n ; i++ ){
      int a,b;
      char ch;
      cin >> a >>ch>> b;
      amida[i][a][b]=amida[i][b][a]=1;
    }

    int from;
    for(int i = 1; i <= w ; i++ ){
      from = i;
      for(int depth = w ; depth >= 1 ; depth-- ){

	for(int to = 1 ; to <= w ; to++ ){
	  if(amida[depth][from][to] == 1){
	    from = to;
	    break;
	  }
	}

      }
      cout << from << endl;
    }

  }
  return 0;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	int a[n];
	for(int i = 0; i < n; i++){
		a[i] = i+1;
	}
	for(int i = 0; i < m; i++){
		int p, q;
		char trash;
		cin >> p >> trash >> q;
		swap(a[p-1],a[q-1]);
	}
	for(int i = 0; i < n; i++){
		cout << a[i] << endl;
	}
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

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

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

using namespace std;

int main(){
    int w,n;
    int i,j;
    char c;
    cin >> w;
    cin >> n;
    vector<pair<int,int> > yokos(n+1);
    vector<int> result(w);
    for(i=0;i<n;++i){
        cin >> yokos[i].first >> c >> yokos[i].second;
    }
    for(i=1;i<=w;++i){
        int current = i;
        for(j=0;j<n;++j){
            if(yokos[j].first == current)
                current = yokos[j].second;
            else if(yokos[j].second == current)
                current = yokos[j].first;
        }
        result[current-1] = i;
    }
    for(i=0;i<w;++i){
        cout << result[i] << endl;
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

int main() {
	int a,b;
	char c;
	cin >> a >> b;
	int x[a];
	int m,n,p;
	for(int i = 0;i<a;i++){
		x[i] = i+1;
	}

	for(int j = 0;j<b;j++){
		cin >> n >> c >> m;
		m--;
		n--;
		p = x[m];
		x[m] = x[n];
		x[n] = p;
	}
	for(int k = 0;k<a;k++){
		cout << x[k] << endl;
	}


	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

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

C++: #include "bits/stdc++.h"
using namespace std;

int main() {
  int w,n;
  cin >>w >> n;
  vector <int> tate(w);

  for(int i=0;i<w;i++){// 配列tateに順に1-wを入力
    tate.at(i)=i+1;
  }
  
  while (n--) {
		int a, b;
		scanf("%d,%d", &a, &b);
		a--; b--;
		swap(tate.at(a), tate.at(b));
	}

    for(int i=0;i<w;i++){// 配列tateを左から順に出力
    cout << tate.at(i)<<endl;
  }
	return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

int dp[60];

int main()
{
	int w(0),n(0);
	REP(i, 60){
		dp[i] = i;
	}
	cin >> n >> w;
	REP(i, w){
		int a, b;
		char c;
		scanf_s("%d,%d", &a,&b);
		swap(dp[a], dp[b]);
	}
	REP(i, n){
		cout << dp[i+1] << endl;
	}
}

C++: #include<stdio.h>
using namespace std;
const int MAX = 100;
int main() {
	int W, N;
	int t[MAX];

	cin >> W >> N;
	for (int i = 0; i < W; i++) {
		t[i] = i;
	}
	for (int i = 0; i < N; i++) {
		int a, b;
		scanf("%d,%d", &a, &b); a--; b--;
		swap(t[a], t[b]);
	}
	for (int i = 0; i < W; i++) {
		printf("%d\n", t[i] + 1);
	}
	return 0;
}