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>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int w;
	while(cin>>w){
		vector<pair<int, int> > all;
		int n;
		cin>>n;
		for(int i=0; i<n; i++){
			int a, b;
			scanf("%d,%d", &a, &b);
			all.push_back(pair<int, int>(a, b));
		}
		reverse(all.begin(), all.end());
		for(int i=1; i<=w; i++){
			int ima = i;
			for(int j=0; j<n; j++){
				if(all[j].first == ima){
					ima = all[j].second;
				} else if(all[j].second == ima){
					ima = all[j].first;
				}
			}
			cout<<ima<<endl;
		}
	}
}

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

struct THorizonalLine
{
	int Left;
	int Right;
};

int main()
{
	int w;
	cin >> w;
	int n;
	cin >> n;
	vector<int> StartingPoint(w);
	for(int i = 0; i < w; i++){
		StartingPoint[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		THorizonalLine HorizonalLine;
		scanf("%d,%d",&HorizonalLine.Left,&HorizonalLine.Right);
		swap(StartingPoint[HorizonalLine.Left-1], StartingPoint[HorizonalLine.Right-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}

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

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

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

int main()
{
	int w, n;
	int a, b;
	
	scanf("%d%d", &w, &n);

	vector<int> num(w + 1);

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

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

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

	return (0);
}

C++: #include <stdio.h>

inline void swap(int array[], int a, int b){
	int c = array[a];
	array[a] = array[b];
	array[b] = c;
}

int main(){
	int array[50];
	int w,n,a,b;

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int w,i,n,l,r;scanf("%d\n%d\n",&w,&n);
    int a[w];
    for(i=0;i<w;i++) a[i] = i+1;
    for(i=0;i<n;i++){
        scanf("%d,%d\n",&l,&r);
        swap(a[l-1],a[r-1]);
    }
    for(i=0;i<w;i++) printf("%d\n",a[i]);
}

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

C++: #include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

void swap(int& x, int& y) {
  int tmp = x;
  x = y;
  y = tmp;
}

int main() {
  int w, n;
  int ws[30];
  cin >> w;
  REP(i,w-1) { ws[i] = i+1; }
  cin >> n;
  REP(i,n-1) { 
    char dummy;
    int a, b;
    cin >> a;
    cin >> dummy;
    cin >> b;
    swap(ws[a-1], ws[b-1]);
  }
  REP(i,w-1) { cout << ws[i] << endl; }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_b) - 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

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

int main() {
    int num;
    scanf("%d",&num);
    int amida[num+1];
    for(int i = 0;i <= num; i++){
        amida[i] = i;
    }
    
    int bars;
    scanf("%d",&bars);
    int a,b;
    
    for(int i = 0; i < bars;i++){
        (cin>>a).ignore()>>b;
        swap(amida[a], amida[b]);
    }
    
    for(int i = 1; i <= num;i++){
        cout<<amida[i]<<endl;
    }
    return 0;

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[32];
	int i,j,k,n,m;
	char c;
	for(i=0;i<32;i++){
		a[i]=i;
	}
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>j>>c>>k;
		swap(a[j],a[k]);
	}
	for(i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.clear();
    cin.ignore();
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_b) - 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

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

int main(){
  int w, n;
  vector<int> que;
  cin >> w >> n;
  for(int i = 1;i <= w;i++) que.push_back(i);
  for(int i = 0;i < n;i++){
    int a, b;
    scanf("%d,%d", &a, &b);
    swap(que[a-1], que[b-1]);
  }

for(int i = 0;i < w;i++){
  cout << que[i] << "\n";
}
  return 0;
}

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

int main(){
    int s[50]={},w,n,a,b,i;
    cin >> w;
    for(i=1;i<=w;i++){
        s[i] = i;
    }
    cin >> n;
    for(i=1;i<=n;i++){
        scanf("%d,%d",&a,&b);
        swap(s[a],s[b]);
    }
    for(int i=1;i<=w;i++){
        cout << s[i] << endl;
    }
    return 0;
}

C++: #include <cstdio>

void swap(int array[], int a, int b){
	int c = array[a];
	array[a] = array[b];
	array[b] = c;
}

int main(){
	int array[50];
	int w,n,a,b;

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

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

using namespace std;

int main(){
    int w, n, a, b;
    vector<pair<int, int>> h_lines;
    cin >> w >> n;
    vector<int> res(w+1);
    while(scanf("%d,%d",&a,&b)+1){
     h_lines.push_back(pair<int, int>(a,b));   
    }
    
    
    for (int i = 1; i <= w; ++i){
        int where = i;
        for (auto line:h_lines){
            if (line.first == where){
                where = line.second;
            } else if (line.second == where){
                where = line.first;
            }
        }
        res[where] = i;
    }
    
    for (auto itr = res.begin()+1; itr != res.end(); ++itr){cout << *itr << "\n";}
    
 return 0;   
}