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 <cstdio>
#include <cmath>

#define MAX_N 30
#define MAX_W 30

void swap(int* a, int* b){
    int temp=0;
    temp = *a;
    *a = *b;
    *b = temp;
}

int main(){
    int w,n,ans[MAX_W];
    int a[MAX_N], b[MAX_N];

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

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

    // Solve
    for(int i = 0; i < n; i++){
        swap(&ans[ a[i] - 1 ], &ans[ b[i] - 1 ]);
    }

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



    return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int w, n;
  cin >> w >> n;
  vi v(w);
  iota(all(v), 1);
  rep(i, n) {
    int a, b;
    char gomi;
    cin >> a >> gomi >> b;
    a--;
    b--;
    swap(v[a], v[b]);
  }
  rep(i, w) cout << v[i] << endl;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int bow, n, number[30]={}, a, b;
    char commma;
    cin >> bow >> n;
    for(int i=1; i<=bow; i++){
        number[i]=i;
    }
    for(int i=0; i<n; i++){
        cin >> a >> commma >> b;
        int tmp=number[a];
        number[a]=number[b];
        number[b]=tmp;
    }
    for(int i=1; i<=bow; i++){
        cout << number[i] << endl;
    }
    return 0;
}

C++: 
//Nayeem Shahriar Joy ,Applied Physics And Electronic Engineering , University of Rajshahi.


#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<string>

using namespace std;

int main()

{

  ios_base::sync_with_stdio(false);

  cin.tie(NULL);

  int T,n,x,b,w;

  char s;

  cin>>w;

  int a[w];

  for(int i=0;i<w;i++)

  {
      a[i]=i+1;
  }

  cin>>n;

  while(n--)

  {
      cin>>x>>s>>b;

      swap(a[x-1],a[b-1]);

  }

   for(int i=0;i<w;i++)

   {
       cout<<a[i]<<endl;
   }


  return 0;

}

C++: #include <iostream>
using namespace std;
#include <string>
#define W 30
#define N 30

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

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

int main(){
	int str[30];
	int w, n, i;
	int a, b;
	int t;

	cin >> w;
	cin >> n;

	for (i = 0; i < 30; i++){
		str[i] = i + 1;
	}

	for (i = 0; i < n; i++){
		scanf("%d,%d", &a, &b);
		
		t = str[a - 1];
		str[a - 1] = str[b - 1];
		str[b - 1] = t;
	}
	for (i = 0; i < w; i++){
		cout << str[i] << "\n";
	}
	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",&bou[j][1]);
		printf(",");
		scanf("%d",&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<iostream>
#include<vector>
#include<algorithm>
#include<string>

#define add push_back
#define inf 2147000000

#define rep(i,n) for(int i=0;i<n;i++)
#define out(a) cout<<a<<endl;

using namespace std;

int main(void){
	int w,h;
	int y1[30],y2[30],t[31];
	string str;
	scanf("%d%d",&w,&h);
	rep(i,h){
		cin>>str;
		int m;
		rep(j,4)if(str[j]==','){m=j;break;}
		
		switch(m){
			case 1:
				y1[i]=str[0]-48;
				break;
			case 2:
				y1[i]= (str[0]-48)*10;
				y1[i]+=str[1]-48;
				break;
		}
		if(str[m+2]!='\0'){
			y2[i] = (str[m+1]-48) * 10;
			y2[i] += str[m+2]-48;
		}else{
			
			y2[i] = str[m+1]-48;
		}
	}
	rep(i,31)t[i]=i;
	
	rep(i,h){
		swap(t[y1[i]],t[y2[i]]);
	}
	
	rep(i,w)out(t[i+1]);
}

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


int main()
{
	int w, n, num[32];
	string s;
	cin >> w;
	fill(num, num + 32, 0);
	for (int i = 1; i < w + 1; i++){
		num[i] = i;
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		string l, r;
		int commapos;

		//カンマの左
		for (int i = 0;; i++){
			if (s[i] == ','){
				commapos = i;
				break;
			}
			else{
				l += s[i];
			}
		}

		//カンマの右
		for (int i = commapos + 1; i < (signed)s.length(); i++){
			r += s[i];
		}
		int left = stoi(l);
		int right = stoi(r);
		int temp = num[left];
		num[left] = num[right];
		num[right] = temp;
	}
	for (int i = 1; i < w + 1; i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
int main(){
	int w,h;
	std::cin>>w>>h;
	std::vector<int> vec(w);
	for(int i=0;i<w;++i)vec[i]=i+1;
	for(int i=0;i<h;i++){
		std::string str;
		std::cin>>str;
		{
			char c=str[0],d=str[2];
			int a=c-'0'-1,b=d-'0'-1;
			int n=vec[a];
			vec[a]=vec[b];
			vec[b]=n;
		}
	}
	for(int i=0;i<w;i++){
		std::cout<<vec[i]<<std::endl;
	}

	return 0;
}