Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	n := nextInt()

	numbers := make([]int, w+1)
	for i := 1; i <= w; i++ {
		numbers[i] = i
	}

	for i := 0; i < n; i++ {
		line := nextString()
		words := strings.Split(line, ",")
		a, _ := strconv.Atoi(words[0])
		b, _ := strconv.Atoi(words[1])

		numbers[a], numbers[b] = numbers[b], numbers[a]
	}

	for i := 1; i <= w; i++ {
		fmt.Println(numbers[i])
	}
}

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

C++: #include <iostream>
#include <algorithm>
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++){
		int p, q;
		char trash;
		cin >> p >> trash >> q;
		swap(a[p-1],a[q-1]);
	}
	for(int i = 0; i < n; i++){
		cout << a[i] << endl;
	}
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#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 <vector>
#include <utility>

using namespace std;

int main(){
    int w,n;
    int i,j;
    char c;
    cin >> w;
    cin >> n;
    vector<pair<int,int> > yokos(n+1);
    vector<int> result(w);
    for(i=0;i<n;++i){
        cin >> yokos[i].first >> c >> yokos[i].second;
    }
    for(i=1;i<=w;++i){
        int current = i;
        for(j=0;j<n;++j){
            if(yokos[j].first == current)
                current = yokos[j].second;
            else if(yokos[j].second == current)
                current = yokos[j].first;
        }
        result[current-1] = i;
    }
    for(i=0;i<w;++i){
        cout << result[i] << endl;
    }

    return 0;
}