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

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

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] , array[b] );
	}
	for(int i=1 ; i<=w ; i++){
		printf("%d\n", array[i]);
	}
}

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

int main() {
	int w, n, i, x, y, z;
	char str[10], *a, *b;
	cin >> w >> n;
	vector<int> A(w);
	for (i = 0; i < w; i++) A[i] = i + 1;
	for (i = 0; i < n; i++) {
		cin >> str;
		a = strtok(str, ","); 
		x = atoi(a);
		b = strtok(NULL, ","); 
		y = atoi(b);
		z = A[x - 1];
		A[x-1] = A[y-1]; A[y-1] = z;
	}
	for (i = 0; i < w; i++) cout << A[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_s("%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<iostream>
#include<vector>
using namespace std;
int main() {
	int w, n, a, b,c;
	vector<int> s;
	cin >> w >> n;
	for (int j = 1; j <= w; j++) {
		s.push_back(j);
	}
	for (int i = 0; i < n; i++) {
		(cin >> a).ignore() >> b;
		c = s[a - 1];
		s[a - 1] = s[b - 1];
		s[b - 1] = c;
	}
	for (int k = 0; k < w; k++) {
		cout << s[k] << endl;
	}
	return 0;
}