Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

C++: #include <iostream>
#include <cstdio>
#include <stdio.h>
using namespace std;
int main(){
	int w,n;
	int a,b,c;
	cin>>w;
	cin>>n;
	int num[30] = {0};
	for(int i=-0;i<w;i++){
		num[i] = i+1;
	}
	for(int j=0;j<n;j++){
		scanf("%d,%d",&a,&b);
		c = num[a-1];
		num[a-1] = num[b-1];
		num[b-1] = c;
	}
	for(int k=0;k<w;k++){
		printf("%d\n",num[k]);
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

struct stick {
  int a;
  int b;
};

int w, n;

int main() {
  int i;
  cin >> w;
  cin >> n;
  stick s[n];
  char split;

  for(i = 0; i < n; i++)
    cin >> s[i].a >> split >> s[i].b;

  for(i = 1; i <= w; i++) {
    int start = i;
    int j;

    for(j = n - 1; 0 <= j; j--) {
      int flag = start;
      if(start == s[j].a)
	flag = s[j].b;
      if(start == s[j].b)
	flag = s[j].a;
      start = flag;
    }
    cout << start << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;

double dist(double x1, double y1, double x2, double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main(){
	int w, n;

	char bar[10];
	vector<int> a(31);
	const char delim = ',';
	int left, right;

	for(int i = 1; i <= 30; i++){
		a[i] = i;
	}

	cin >> w >> n;

	while(n--){
		cin >> bar;
		left = atoi(strtok(bar, &delim));
		right = atoi(strtok(NULL, &delim));
		swap(a[left], a[right]);
	}

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

	return 0;
}

C++: //43
#include<iostream>

using namespace std;

int main(){
  int lot[31];
  for(int i=1;i<=30;i++){
    lot[i]=i;
  }
  int w,n;
  cin>>w>>n;
  for(int i=0;i<n;i++){
    int a,b;
    (cin>>a).ignore()>>b;
    swap(lot[a],lot[b]);
  }
  for(int i=1;i<=w;i++){
    cout<<lot[i]<<endl;
  }
  return 0;
}

C++:  #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int w,n,i,r,l,tmp,res[31];
  for(i=1;i<=30;i++)
      res[i]=i;
  cin >> w;
  cin >> n;
  for(i=0;i<n;i++)
  {
    scanf("%d,%d",&l,&r);
    tmp=res[l];
    res[l]=res[r];
    res[r]=tmp;
  }
  for(i=1;i<=w;i++)
    cout << res[i] << endl;
  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 << endl;
}

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

C++: #include <bits/stdc++.h>

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;



int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int w = 0, n = 0;
	std::cin >> w >> n;

	std::vector<int> A(w + 1);
	std::iota(A.begin(), A.end(), 0);

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

		int a = 0, b = 0;
		std::string temp;
		std::cin >> temp;
		a = std::stoi(temp.substr(0, temp.find(',', 0)));
		b = std::stoi(temp.substr(temp.find(',', 0) + 1, temp.length()));
		std::swap(A[a], A[b]);

	}

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

}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

void input();
void calc();
void output();

int main(void)
{

	input();
	calc();
	output();
}


int n,m;
std::vector<int> line;

void set_line()
{
	for (int i = 0; i < n; i++)
	{
		line.push_back(i + 1);
	}
}

void input()
{
	cin >> n >> m;
	set_line();

}

void calc()
{
	int a, b;
	char c;
	for (int i = 0; i < m; i++)
	{
		cin >> a >> c  >> b;
		swap(line[a - 1], line[b - 1]);
	}

}

void output()
{
	for (int i = 0; i < n; i++)
	{
		cout << line[i] << endl;
	}
}

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;
	rep(i, n)
		num[i] = i + 1;		
	std::cin >> w >> n;
	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>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;

const int IMAX = ((1<<30)-1)*2+1 ;
const int INF = 100000000;
double EPS = 1e-10 ;

int main(){
  char c;
  int w,n,a,b,num,ans[5];
  bool flag = true;
  cin >> w >> n;
  vi v(w,0),va,vb ;
  rep(i,n){
    cin >> a >> c >> b ;
    va.pb(a),vb.pb(b) ;
  }

  rep(i,w){
    num = i+1 ;
    rep(j,n){
      if(num == va[j]){
        num = vb[j];
      }
      else if(num == vb[j]){
        num = va[j];
      }
    }
    ans[num-1] = i+1;
  }
  for(auto tmp :ans){
    cout << tmp << endl;
  }
  return 0;
}

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

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

C++: #include<stdio.h>
int line[30];
int n,m;
int a,b;
int mem[2];

int main()
{
    scanf("%d",&n);
    scanf("%d",&m);
    for(int i=0;i<n;i++)
    {
        line[i]=i+1;
    }
    for(int i=0;i<m;i++)
    {
        scanf("%d,%d",&a,&b);
        mem[0]=line[a-1];
        mem[1]=line[b-1];
        line[a-1]=mem[1];
        line[b-1]=mem[0];
    }
    for(int i=0;i<n;i++)
    {
        printf("%d\n",line[i]);
    }
}

C++: #include <stdio.h>

int main(void)
{
	int w,n;
	int l1, l2;
	int ans[30];
	int i;
	
	scanf("%d %d", &w, &n);
	
	for (i = 0; i < w; i++){
		ans[i] = i + 1;
	}
	
	while (n){
		scanf("%d%*c%d", &l1, &l2);
		
		ans[l1 - 1] += ans[l2 - 1];
		ans[l2 - 1] = ans[l1 - 1] - ans[l2 - 1];
		ans[l1 - 1] -= ans[l2 - 1];
		
		n--;
	}
	
	for (i = 0; i < w; i++){
		printf("%d\n", ans[i]);
	}
	
	return (0);
}

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

using namespace std;

int w,n;
int v[30];

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