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 <bits/stdc++.h>
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;
  
int main() {
int w,n; cin >> w >> n;
int a[31];
rep(i,0,w) a[i] = i+1;
  
rep(i,0,n) {
int x,y;
scanf("%d,%d",&x,&y);
swap(a[x-1],a[y-1]);
}
rep(i,0,n) cout << a[i] << endl;
return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int h,v,i,l,r;
int a[30];
for (i=0;i<30;i++) a[i]=i;
cin >> h >> v;
for (i=0;i<v;i++) {
	cin >> l >> r ;
	swap(a[l],a[r]);
}
for (i=1;i<=h;i++) cout << a[i] << endl;
return 0;
}

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

int main() {
    std::vector<int> v;
    
    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
        v.push_back(i);
    }
    
    int n;
    scanf("%d", &n);
    
    int a, b;
    while (~scanf("%d,%d", &a, &b)) {
        std::swap(v[a - 1], v[b - 1]);
    };
    
    for (const auto& i : v) {
        printf("%d\n", i + 1);
    }
}

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

int main(){
	int w,n;
	cin>>w>>n;
	int c[31];
	int a,b;
	for(int x=1;x<=w;x++){
		c[x]=x;
	}
	for(int y=0;y<n;y++){
		scanf("%d,%d",&a,&b);
		swap(c[a],c[b]);
	}
	for(int z=1;z<=w;z++){
		cout<<c[z]<<endl;
	}
	return 0;
	}

C++: #include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxw=30+5;
int w,n,rank[maxw];
int main(){
    scanf("%d%d",&w,&n);
    for(int i=1;i<=w;i++)
        rank[i]=i;
    for(int i=1,x,y;i<=n;i++){
        scanf("%d,%d",&x,&y);
        swap(rank[x],rank[y]);
    }
    for(int i=1;i<=w;i++)
        cout<<rank[i]<<endl;
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
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++){
		stringstream ss1, ss2;
		string str;
		int p, q;
		cin >> str;
		ss1 << str[0];
		ss2 << str[2];
		ss1 >> p;
		ss2 >> q;
		swap(a[p-1],a[q-1]);
		
	}
	for(int i = 0; i < n; i++){
		cout << a[i] << endl;
	}
}

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

int main() {
	int w, n;
	string str;
	cin >> w >> n;
	int ami[30];
	for (int i = 0; i < w; i++) {
		ami[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		int a, b, temp;
		string str;
		cin >> a >> b;
		temp = ami[a-1];
		ami[a-1] = ami[b-1];
		ami[b-1] = temp;
	}
	for (int i = 0; i < w; i++) {
	cout << ami[i] <<endl;
	}

	return 0;
}

C++: #include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

int num[31];

int main(){
    rep(i,31)num[i]=i;
    int x,y;
    cin>>x>>y;
    
    int n,m;
    char b;
    rep(i,y){
        cin>>n>>b>>m;
        swap(num[n],num[m]);
    }
    for(int i=1;i<x+1;i++){
        cout<<num[i]<<endl;
    }
    return 0;
}

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

int main(){
	
	int w,n;
	char con;
	cin>>w>>n;
	vector<int> s(w);
	vector<int> a(n);
	vector<int> b(n);
	
	for(int i=0;i<w;i++)
		s[i]=i+1;
	
	for(int i=0;i<n;i++)
		cin>>a[i]>>con>>b[i];
	
	for(int i=0;i<n;i++)
		swap(s[a[i]-1],s[b[i]-1]);
	
	for(int i=0;i<w;i++)
		cout<<s[i]<<endl;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int w, n, ans[31];
	cin >> w >> n;
	for (int i = 0; i <= 30; i++)
		ans[i] = i;
	for (int i = 0; i < n; i++) {
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap(ans[a], ans[b]);
	}
	for (int i = 1; i <= 30; i++)
		cout << ans[i] << endl;
}

C++: #include <iostream>
using namespace std;
void change(int num[],int a, int b)
{
	int tmp = num[a];
	num[a] = num[b];
	num[b] = tmp;
}
int main()
{
	int w,n;
	int order[30]={0};
	cin >> w >> n;
	for(int i=0; i < w; i++){
		order[i] = i;
	}
	while(n--){
		int a,b;
		scanf("%d , %d ", &a, &b);
		change(order, a-1, b-1);
	}
	for(int i=0; i< w; i++){
		cout << order[i]+1 << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstring>

using namespace std;

int main(){
    int w, n;
    int d[31];
    while(cin >> w >> n){
        for(int i=1;i<=w;i++) d[i] = i;
        for(int i=0;i<n;i++){
            string s; cin >> s;
            istringstream iss >> s;
            for(int j=0;j<s.size();j++)
                if(s[j]==',') s[j] = ' ';
            int a, b; iss >> a >> b;
            swap(d[a], d[b]);
        }
        for(int i=1;i<=w;i++) cout << d[i] << endl;
    }
}

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

vector<int> ans(31);

void swap(int a, int b){
  int tmp = ans[a];
  ans[a] = ans[b];
  ans[b] = tmp;
}

int main(){
  int w, n;

  cin >> w >> n;
  for(int i=1; i<=w; i++) ans[i] = i;

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

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

C++: #include<iostream>
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

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

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

using namespace std;

int nums[100];
int main() {
  int w, n;
  scanf("%d %d", &w, &n);
  for (int i = 1; i <= w; i++) {
    nums[i] = i;
  }
  while (n--) {
    int a,b;
    scanf("%d,%d", &a, &b);
    swap(nums[a], nums[b]);
  }
  for (int i = 1; i <= w; i++) {
    printf("%d\n", nums[i]);
  }
}

C++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++)
int main()
{
	int w, n;

	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	int a[32];
	roop(i, 32) {
		a[i] = i + 1;
	}
	roop(i, n) {
		string s;
		cin >> s;
		string d[2];
		roop(i, s.length) {
			if (s[i] == ',') { d[0] = s.substr(0, i); d[i] = s.substr(i + 1); break; }
		}
		int swap[2];
		roop(i, 2) {
			swap[i] = stoi(d[i]);
		}
		int before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	roop(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

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

int main(){

	int w, n;
	int num[30] = { 0 };
	int a, b;
	char c

	cin >> w;
	cin >> n;

	for (int i = 0; i<w; i++)
		num[i] = i + 1;

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

		cin >> a >> c >> b;


		int tmp = num[a-1];
		num[a-1] = num[b-1];
		num[b-1] = tmp;


	}


	for (int i = 0; i<w; i++)
		cout << num[i] << "\n";

	return 0;

}