Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	lines, _ := strconv.Atoi(sc.Text())
	l := make([]int, lines)
	for i := 0; i < lines; i++ {
		l[i] = i + 1
	}

	sc.Scan()
	rows, _ := strconv.Atoi(sc.Text())
	for i := 0; i < rows; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), ",")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])

		l[a-1], l[b-1] = l[b-1], l[a-1]
	}
	for _, j := range l {
		fmt.Println(j)
	}
}

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

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int n , w , i , j , a , b;
	int number[40] ;
	cin >> w ;
	cin >> n;
	for( i=1 ; i<=n ; i++ ){
		scanf( "%d,%d" , &a , &b );
		int x = number[a];
		number[a] = number[b];
		number[b] = x ;
	}
	for( i=1 ; i<=w ; i++ )
		cout << number[i] << endl;
}

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

class Amidakuji{

public:
	int W;
	vector<int> array;//????´?1???????????????
	Amidakuji(int w);
	void Swap(int x,int y);
	void call();
};

//????????????????????????????????????
Amidakuji::Amidakuji(int w){

	for (int i = 0; i < w; i++){
		array.push_back(i+1);//[0,1,2,3,4]={1,2,3,4,5}
	}
	
	W = w;

}

void Amidakuji::Swap(int x,int y){

	//???????????£????????????array[]???????????????
	//int?????§???????????£????????§char???int?????????????????????-48;
	x -= 48;
	y -= 48;
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	for (int i = 0;i<W; i++){
		cout << array[i];
	}cout << endl;


}

void Amidakuji::call(){

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

}

int main(){

	int w, n;
	string text;

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			cout << i<<endl;
			getline(cin, text);
			if (text[0] != 0 && text[2] != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(text[0], text[2]);
				text[0] = text[2] = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}


	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#define N 30
using namespace std;
int main(){
  int w,n,tmp;
  int lod[N]; int lis[N][3];
  while(cin >> n >> w){
  for(int i = 0;i<n;i++){
    lod[i] = i+1;
  }

  for(int i=0;i<w;i++){
    scanf("%d,%d",&lis[i][0],&lis[i][2]);
  }
  for(int i=0;i<w;i++){
    tmp = lod[lis[i][0]-1];
    lod[lis[i][0]-1] = lod[lis[i][2]-1];
    lod[lis[i][2]-1] = tmp;
  }
  for(int i=0;i<n;i++){
    cout << lod[i] << endl;
  }
  }
}

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

int main(void){
  int s[30];
  int w,n;

  for(int i = 0;i<30;i++) s[i] = i;

  cin >> w;
  cin >> n;

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

  for(int i = 1;i<=w;i++) cout << s[i] << endl;

  return 0;
}