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<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int w, n; 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	ll a[32];
	roop(i, 32) {
		a[i] = i + 1;
	}
	roop(i, n) {
		string s;
		cin >> s;
		string d[2];
		roop(i, s.length) {
			if (s[i] == ',') { d[0] = s.substr(0, i); d[i] = s.substr(i + 1); break; }
		}
		int swap[2];
		roop(i, 2) {
			swap[i] = stoi(d[i]);
		}
		int before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	roop(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include <algorithm>

#include <stdio.h>

int main(int argc, char** argv)
{
  int w, n;

  fscanf(stdin, "%d", &w);
  
  int ind[30] = { 1,  2,  3,  4,  5,  6,  7,  8,  9, 10,
		 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
		 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
  };

  fscanf(stdin, "%d", &n);
  
  for (int i = 0; i < n; i ++) {
    int a, b;

    fscanf(stdin, "%d,%d", &a, &b);
    
    std::swap(ind[a - 1], ind[b - 1]);
  }
  
  for (int i = 0; i < w; i ++)
    fprintf(stdout, "%d\n", ind[i]);
}

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

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

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

int main(){
    int line[40]={};
    int linenum;
    int change;
    cin>>linenum>>change;
    for(int i=1; i<linenum+1; i++){
        line[i]=i;
    }
    int sw,ap;
    char waste;
    for(int i=0; i<change; i++){
        cin>>sw>>waste>>ap;
        swap(line[sw],line[ap]);
    }
    for(int i=1; i<linenum+1; i++){
        cout<<line[i]<<endl;
    }
    return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int w,n,a,b,i,t,h[50];
	
	scanf("%d\n%d",&w,&n);

	for(i=1;i<=w;i++)
		h[i]=i;

	i=0;

	while(i<n)
	{
		scanf("%d,%d",&a,&b);
		t=h[a];
		h[a]=h[b];
		h[b]=t;
		i+=1;
	}
	for(i=1;i<=w;i++)
	{
	  printf("%d\n",h[i]);
	}

 return 0;
}

C++: #include <stdio.h>

void swap(int* a,int* b);

int main(void) {

  int w,n;
  int seq[50];
  int a,b;
  int i;
  
  scanf("%d",&w);

  for(i=0;i<w;i++) seq[i]=i+1;

  scanf("%d",&n);

  for(i=0;i<n;i++) {
    scanf("%d,%d",&a,&b);
    swap(seq+a-1,seq+b-1);
    }

  for(i=0;i<5;i++) printf("%d\n",seq[i]);
 
  return 0;
}

void swap(int* a,int* b) {
  int temp;

  temp=*a;
  *a=*b;
  *b=temp;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <bitset>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<long long int,long long int> 
#define ff first
#define pb push_back
#define ss second
#define ll long long 
#define ull unsigned long long
#define vi vector<long long int>
#define vii vector<pii>
#define vvi vector <vi>
#define rep(x,a,b,c) for(int x=a;x<=b;x+=c)
#define repp(x,a,b) rep(x,a,b,1)
#define rev(x,a,b,c) for(int x=a;x>=b;x-=c)
#define revv(x,a,b) rev(x,a,b,1)
#define OO (int)2e9
#define INF (ll)1e18
 
using namespace std;

int n,list[50],a,b,k;

int main()
{
	scanf("%d",&n);
	repp(x,1,n)
	{
		list[x]=x;
	}
	scanf("%d",&k);
	repp(x,1,k)
	{
		scanf("%d,%d",&a,&b);
		swap(list[a],list[b]);
	}
	repp(x,1,n)
	{
		printf("%d\n",list[x]);
	}
	return 0;
}

C++: #include <iostream>
#include <stdlib.h>
#include <string.h>
#include <sstream>

using namespace std;

int main()
{
    int w,n;
    int A[100];
    while(cin >> w >> n)
    {
        for(int i=0; i<w; i++)
            A[i] = i + 1;
        string str;
        for(int i=0; i<n; i++)
        {
            cin >> str;
            int len = str.length();
            int d = str.find(',',0);
            string str1 = str.substr(0,d);
            string str2 = str.substr(d+1,len-1);
            str1 = str1 + " " + str2;
            int a;
            istringstream issInt(str1);
            issInt >> a;
            int b;
            issInt >> b;
            int t = A[a-1];
            A[a-1] = A[b-1];
            A[b-1] = t;
        }
        for(int i=0; i<w; i++)
            cout << A[i] << endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(void){
  int w=0, n=0;
  int a[30], b[30], c[30];
  int i, j, tmp;

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

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

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

 
  //printf("test----------\n");

  for (i=0; i<n; i++){
  	tmp = c[a[i]-1];
    c[a[i]-1] = c[b[i]-1];
    c[b[i]-1] = tmp;
    /*
    for (j=0; j<w; j++) {
  	  printf("%d ", c[j]);
    }
    printf("\n");*/
  } 

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

  return 0;
}

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("%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>

using namespace std;

int main() {
	int w, n, t, a, b;
	char c;
	cin >> w;
	if (w <= 0) return -1;
	vector<int> state(w);
	for (int i = 1; i <= w; i++)
		state[i-1] = i;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> c >> b;
		t = state[a - 1];
		state[a - 1] = state[b - 1];
		state[b - 1] = t;
	}
	for (int i = 0; i < w; i++)
		cout << state[i] << endl;
	return 0;
}

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

using namespace std;

typedef struct st_crossBar{
	int left;
	int right;
} CrossBar;

int main(void)
{
	int w = 0, n = 0;
	cin >> w >> n;
	
	vector<CrossBar> crossBarVec;
	for(int i = 0; i < n; i++){
		CrossBar crossBar = {0};
		
		char c;
		cin >> crossBar.left >> c >> crossBar.right;
		crossBarVec.push_back(crossBar);
	}
	
	vector<int> underNumVec;
	underNumVec.resize(w);
	
	for(int i = 1; i <= w; i++){
		int num = i;
		for(int j = 0; j < n; j++){
			if(num == crossBarVec[j].left){
				num = crossBarVec[j].right;
			}
			else if(num == crossBarVec[j].right){
				num = crossBarVec[j].left;
			}
			else{
				;
			}
		}
		
		underNumVec[num - 1] = i;
	}
	
	for(int i = 0; i < w; i++){
		cout << underNumVec[i] << endl;
	}
	
	return 0;
}