Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func swap(ints []int, i, j int) {
	ints[i], ints[j] = ints[j], ints[i]
}

func main() {
	w := nextInt()
	// println(w)
	nums := make([]int, w)
	for i := range nums {
		nums[i] = i+1
	}
	n := nextInt()
	// println(n)
	for i := 0; i < n; i++ {
		info := nextString()
		// println(info)
		infos := strings.Split(info, ",")
		a, _ := strconv.Atoi(infos[0])
		b, _ := strconv.Atoi(infos[1])
		swap(nums, a-1, b-1)
	}
	for _, v := range nums {
		fmt.Println(v)
	}
}

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

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

    int *progression = new int[w + 1];
    for (int i = 1; i <= w; ++i) {
        progression[i] = i;
    }

    for (int i = 0; i < n; ++i) {
        int a, b;
        char comma;
        cin >> a >> comma >> b;

        int tmp = progression[a];
        progression[a] = progression[b];
        progression[b] = tmp;
    }

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

    delete[] progression;
}

C++: #include<iostream>
int main(){
	int w,n,a[30][2],b[30];
	std::cin>>w
		>>n;
	for(int i=0;i<n;++i){
		for(int j=0;j<2;++j){
			std::cin>>a[i][j];
		}
	}
	for(int i=1;i<=w;++i){
		b[i]=i;
	}
	for(int i=0;i<n;++i){
			int x=b[a[i][0]];
			b[a[i][0]]=b[a[i][1]];
			b[a[i][1]]=x;
	}
	for(int i=1;i<=w;++i){
		std::cout<<b[i]<<std::endl;
	}
	return 0;
}

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

using namespace std;

void swap(int *var1, int *var2) {
  int tmp = *var1;
  *var1 = *var2;
  *var2 = tmp;
}

int main() {
  int w;
  int n;

  cin >> w;
  cin >> n;

  int vertical_line[w];
  for (int v_i = 0; v_i < w; v_i++)
    vertical_line[v_i] = v_i+1;

  for (int n_i = 0; n_i < n; n_i++) {
    int node1, node2;
    scanf("%d,%d", &node1, &node2);
    swap(vertical_line+node1-1, vertical_line+node2-1);    
  }

  for (int v_i = 0; v_i < w; v_i++)
    cout << vertical_line[v_i] << endl;

  return 0;
}

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

int main(){

  int w;
  int n;
  int i;
  int a;
  int b;
  int number[32] = {};

  scanf("%d", &w);
  scanf("%d", &n);

  for(i = 1; i <= w; i++){
    number[i] = i;
  }

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


  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int w,n,c,x,y;
	cin>>w>>n;
	int a[w+1]={0};
	for(int i=0;i<=w;i++)a[i]=i;
	for(int i=0;i<n;i++)
	{
		scanf("%d,%d",&x,&y);
		c=a[x],a[x]=a[y],a[y]=c;
	}
	for(int i=1;i<=w;i++)
	{
		cout<<a[i]<<endl;
	}
	return 0;
}

C++: #include <iostream>

const int W_MAX = 30;
const int N_MAX = 30;

int w;
int n;
int a[N_MAX + 1];
int b[N_MAX + 1];
int out[W_MAX + 1];

void chenge(int *farst, int *second){
	int tmp;
	tmp = *farst;
	*farst = *second;
	*second = tmp;
}

int main(void){
	ios::sync_with_stdio(false);
	std::cin.tie(0);

	std::cin >> w;
	std::cin >> n;

	for(int i = 0; i <= w; i++){
		out[i] = i;
	}

	for(int i = 1; i <= n; i++){
		std::cin >> a[i] >> b[i];
		chenge(&out[a[i]], &out[b[i]]);
	}
	
	for(int i = 1; i <= w; i++){
		std::cout << out[i] << ' ';
	}

	std::cout << '/n';

	return 0;
}

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

using namespace std;

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

    vector<int> v(w);
    for (int i=0; i<w; ++i) v[i] = i + 1;

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

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

    return 0;
}

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;
}