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>

using namespace std;

int main()
{
	int W, N, A[31], B[31], C[31];

	cin >> W >> N;

	for (int i = 1; i <= N; i++)
	{
		cin >> A[i] >> B[i];
	}

	for (int i = 1; i <= W; i++)
	{
		int t = i;

		for (int j = 1; j <= N; j++)
		{
			if (A[j] == t)
			{
				t = B[j];
			}
			else if (B[j] == t)
			{
				t = A[j];
			}
		}

		C[t] = i;
	}

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

	return 0;
}

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

using namespace std;

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

	vector<int> tate(w);

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

	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a;
		cin.ignore(1);
		cin >> b;

		swap(tate[a - 1], tate[b - 1]);
	}

	for (auto temp : tate) {
		cout << temp << endl;
	}

}

C++: //#define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 30
int main(void)
{
	int w, n, a, b, x;
	int list[MAX] = { 0 };
	scanf_s("%d", &w);
	scanf_s("%d", &n);
	for (int i = 0; i < w;++i) {
		list[i] = i + 1;
	}
	for (int i = 0; i < n; ++i) {
		scanf_s("%d,%d", &a, &b);
		x = list[a - 1]; list[a - 1] = list[b - 1]; list[b - 1] = x;
	}
	for (int i = 0; i < w; ++i) {
		printf("%d\n", list[i]);
	}

}

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	int w; cin >> w;
	int n; cin >> n;
	int a, b;
	vector<int>v(w);
	char c;
	for (int i = 0; i < w; i++)v[i] = i + 1;
	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 <cstdio>

using namespace std;

int line[32];
int w, n;

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

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

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

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

void swap(int a[], int k, int l) {
    int tmp = a[k];
    a[k] = a[l];
    a[l] = tmp;
}

int main(void) {
    int w, n, k, l;
    int a[31];
    cin >> w;
    cin >> n;
    for(int i = 1; i <= w; i++) {
        a[i] = i;
    }
    for(int j = 0; j < n; j++) {
        scanf("%d,%d", &k, &l);
        swap(a, k, l);
    }
    for(int i = 1; i <= w; i++) {
        printf("%d\n", a[i]);
    }
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#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 <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

int main()
{
	int w, n, a, b;
	char comma;
	vector<int> vec;

	cin >> w;
	cin >> n;

	for (int i = 1; i <= w; i++)
	{
		vec.push_back(i);
	}

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

	for (auto a : vec)
	{
		cout << a << endl;
	}


	return 0;
}

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

int main()
{
	int w,wl[35],n,a,b,c;
	char ch;
	for(int i=0;i<35;i++){
		wl[i]=i;
	}
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		cin>>ch;
		cin>>b;
		c=wl[a];
		wl[a]=wl[b];
		wl[b]=c;
	}
	for(int i=0;i<w;i++){
		cout<<wl[i+1]<<endl;
	}
}

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

typedef std::pair<int, int> swap_command;

int w, n;
std::vector<int> vertical;
std::vector<swap_command> commands;

swap_command get_command_input()
{
	swap_command cmd;
	char dummy;
	std::cin >> cmd.first >> dummy >> cmd.second;
	return cmd;
}

void init()
{
	std::cin >> w;
	std::cin >> n;

//	std::cout << w << " " << n << std::endl;

	int i;
	for (i = 0; i < w; i++) {
		vertical.push_back(i+1);
	}

	for (i = 0; i < n; i++) {
		commands.push_back(get_command_input());
	}
}

void dump_vertical()
{
	std::cout << "vertical: ";
	for (int i = 0; i < w; i++) {
		std::cout << vertical[i] << ' ';
	}
	std::cout << std::endl;
}

void swap(swap_command cmd)
{
//	std::cout << "fist: " << cmd.first << " second: " << cmd.second << std::endl;
	int i = cmd.first-1;
	int j = cmd.second-1;
	int tmp = vertical[i];
	vertical[i] = vertical[j];
	vertical[j] = tmp;
//	dump_vertical();
}

void solve()
{
	for (std::vector<swap_command>::iterator i = commands.begin(); i != commands.end(); i++) {
		swap(*i);
	}
}

void output()
{
	for (std::vector<int>::iterator i = vertical.begin(); i != vertical.end(); i++) {
		std::cout << *i << std::endl;
	}
}

int main()
{
	init();
	solve();
	output();
	return 0;
}

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


 int main(){

   int w,n,u,t,p;
   cin >> w>>n;
   int a[w];
   for(int i=0; i<w;i++)
    a[i]=i+1;

   for(int i=0; i<n;i++){
     scanf("%d,%d\n",&u,&t);
     p=a[t-1]; a[t-1]=a[u-1];a[u-1]=p;
   }
   for(int i=0; i<w ;i++)printf("%d\n",a[i]);
 }

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

int main() {
	int w, n, a, b;

	cin >> w >> n;
	vector<int> hlines(w);
	for (int i = 0; i < w; ++i) {
		hlines.at(i) = i + 1;
	}

	for (int i = 0; i < n; ++i) {
		cin >> a;
		cin.ignore();
		cin >> b;
		--a, --b;
		swap(hlines.at(a), hlines.at(b));
	}
	for (int i = 0; i < w; ++i) {
		cout << hlines.at(i) << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int w, n;
    char comma;
    int ab[31][2];
    int ans[31];
    
    cin >> w >> n;
    for (int i = 0; i < n; i++)
        cin >> ab[i][0] >> comma >> ab[i][1];

    for (int i = 1; i <= w; i++) {
        int state = i;
        int pos = 0;
        for (int j = 0; j < n; j++) {
            if (pos == 0) {
                if (ab[j][0] == state) {
                    state = ab[j][1];
                    pos = 1;
                }
                else if (ab[j][1] == state) {
                    state = ab[j][0];
                    pos = -1;
                }
            }
            else if (pos == -1 && ab[j][0] == state) {
                state = ab[j][1];
                pos = 1;
            }
            else if (pos == 1 && ab[j][1] == state) {
                state = ab[j][0];
                pos = -1;
            }
        }
        ans[state] = i;
    }

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

    return 0;
}

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

int main() {
	int w, n, a, b;
	int amida[31];
	for (int i = 1;i < 31;i++) amida[i] = i;
	cin >> w >> n;

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

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

	return 0;
}