Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

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;
	
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	

}

void Amidakuji::call(){

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

}

int main(){


	int w, n,loc,a,b;
	string text,str_a,str_b,str_v;

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);

			//????????¶?????§??????10,2??????????????¨??????{1,0,,,2}??????????????¢????????£?????????????????§??????????????????????????????????????????

			//?????????????????????????????????????????????????????§?????????????????£?????????????????\????????????????????£???
			loc=text.find(",", 0);
			str_a = text[0];
			for (int j = 1; j < loc; j++){
				str_v = text[j];
				str_a = str_a + str_v;

			}
			str_b = text[loc + 1];
			for (int j = loc + 2; j < text.length(); j++){
				str_v = text[j];
				str_b = str_b + str_v;
			}

			
			a = stoi(str_a);
			b = stoi(str_b);


			if (a != 0 && b != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(a, b);
				a = b = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}

	



	return 0;
}

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

int main(){

  int w, n, a, b;
  int x[30];
  char c;

  cin>>w>>n;

  for(int i=0;i<w;i++) x[i]=i+1;
  
  for(int i=0;i<n;i++){
    cin>>a>>c>>b;
    swap(x[a-1], x[b-1]);
  }

  for(int i=0;i<w;i++) cout<<x[i]<<endl;
  
  return 0;
}

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

int main(){
	int w;
	int n;
	int a, b;

	cin >> w >> n;
	
	int number[30];
	for(int i = 0; i < w; i++){
		number[i] = i+1;
	}

	for(int i = 0; i < n; i++){
		scanf_s("%d,%d", &a, &b);
		swap(number[a-1], number[b-1]);
	}
	
	for(int i = 0; i < w; i++){
		cout << number[i] << endl;
	}

	return(0);
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
	int w, n, cp, amd[30] = {0}, yoko[2];
	
	cin >> w >> n;

	for(int i = 1; i <= w; i++)
		amd[i-1] = i;

	for(int i = 0; i < n; i++){
		scanf("%d,%d", &yoko[0], &yoko[1]);

		cp = amd[yoko[0]-1];
		amd[yoko[0]-1] = amd[yoko[1]-1];
		amd[yoko[1]-1] = cp;
	}

	for(int i = 0; i < w; i++)
		cout << amd[i] << endl;
	
	return 0;
}

C++: #include<iostream>

int listen_lineCount();
void listen_path(int &from,int &to);

class Lots
{
private:
	int *start_goal;
	int verLineNum;
public:
	Lots(const int lineCount);
	~Lots();
	
	void draw_line(const int from,const int to);
	void echo_goalNums();
};

//-------------------------main--------------------------------

int main()
{
	int ver_lineCount=listen_lineCount();
	Lots inst_lot=Lots(ver_lineCount);
	
	int hor_lineCount=listen_lineCount();
	
	int from,to;
	for(int roop=0;roop<hor_lineCount;roop++)
	{
		listen_path(from,to);
		inst_lot.draw_line(from,to);
	}
	
	inst_lot.echo_goalNums();
	return 0;
}

//--------------------------------------------------------------

Lots::Lots(const int lineCount)
{
	verLineNum=lineCount;
	start_goal=new int(lineCount+1);
	
	for(int roop=1;roop<=lineCount;roop++)
	{
		start_goal[roop]=roop;
	}
}

Lots::~Lots()
{
	delete [] start_goal;
}

void Lots::draw_line(const int from,const int to)
{
	int swap=start_goal[from];
	start_goal[from]=start_goal[to];
	start_goal[to]=swap;
}

void Lots::echo_goalNums()
{
	using namespace std;
	
	for(int roop=1;roop<=verLineNum;roop++)
	{
		cout<<start_goal[roop]<<endl;
	}
}


int listen_lineCount()
{
	using namespace std;
	
	int lineCount;
	cin>>lineCount;
	
	return lineCount;
}

void listen_path(int &from,int &to)
{
	using namespace std;
	
	char delim;//カンマ区切り
	
	cin>>from>>delim>>to;
}

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

int w,n ;
int x,y ;

int LenLine[31] ;

int main()
{
	cin >> w ;
	cin >> n ;

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

	for( int i = 0 ; i < n ; i ++ )
	{
		cin >> x >> y ;

		swap( LenLine[x] , LenLine[y] ) ;
	}

	for( int i = 0 ; i < w ; i ++ )
	{
		cout << LenLine[i+1] << endl ;
	}

	return 0 ;
}

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

int main(){
  int w,n;
  scanf("%d\n%d",&w,&n);
  int v[w+1],s1,s2;
  for(int i=1;i<=w;i++) v[i]=i;
  for(int i=0;i<n;i++){
    scanf("%d,%d",&s1,&s2);
    swap(v[s1],v[s2]);
  }
  for(int i=1;i<=w;i++) printf("%d\n",v[i]);
  return 0;
}

C++: 

#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

const int MAX_HORIZONTAL = 30;
const int MAX_VERTICAL = 30;

int main(){

	int VerticalLines;
	int HorizontalLines;
	int HorizonA[MAX_HORIZONTAL];
	int HorizonB[MAX_HORIZONTAL];
	int Results[MAX_VERTICAL];



	cin >> VerticalLines;
	cin >> HorizontalLines;
	for (int i = 0; i < HorizontalLines; ++i){ char c[32];  scanf("%d,%d", &HorizonA[i], &HorizonB[i]); }

	for (int i = 0; i < VerticalLines; ++i){ Results[i] = i + 1; }

	

	for (int i = 0; i < HorizontalLines; ++i){
		int Swap = Results[HorizonA[i] - 1];
		Results[HorizonA[i]-1] = Results[HorizonB[i] - 1];
		Results[HorizonB[i] - 1] = Swap;
	}

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





	return 0;
}

C++: #include <iostream>
#include<stdio.h>
#define for1(be,end,z) for(z=be;z<end;z++)
#define for2(end,z) for1(0,end,z)

using namespace std;
int g_lost[30];
/*void init()
{
    int i;
    for2(30,i)
    {
        g_lost[i]=i+1;
    }
}
void swap1(int a,int b)
{
    int tp;
    tp=g_lost[a-1];
    g_lost[a-1]=g_lost[b-1];
    g_lost[b-1]=tp;
}*/
int main()
{
    int w,n,i,tp;
    cin>>w>>n;
    int data[w];
    for2(w,i)
    {
        data[i]=i+1;
    }
    while(n--)
    {
        int a,b;
        scanf("%d,%d", &a, &b);
        tp=data[a-1];
        data[a-1]=data[b-1];
        data[b-1]=tp;
    }
    for2(w,i)
    {
        cout<<data[i]<<endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;
 
int main() {
	
    int L[30] = {};
    for(int i=0;i<30;i++)
	L[i]=i+1;
	
    int a,b;
    cin >> a >> b;
    for(int i=0;i<b;i++){
    	
        int c,d;
        cin >> c >> d;
        
        int s=L[c-1];
        L[c-1]=L[d-1];
        L[d-1]=s;
        
    }
    for(int i=0;i<a;i++)
	cout << L[i] << "\n";
	return 0;
}

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

int main()
{
  int w,n;
  int c[]={0};
  int a,b;
  //  int temp;

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

  for(int i=0; i<=n; i++){
    c[i]=i;
  }

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

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

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

int main(){
	
	int w,n;
	int a,b;
	char c;
	int temp;
	int x[31]={};
	
	cin >> w >> n ;
	
	for( int i=1 ; i<=w ; i++ ) x[i]=i;
	
	for( int i=0 ; i<n ; i++ ){
		cin >> a >> c >> b ;
		
		temp=x[a];
		x[a]=x[b];
		x[b]=temp;
	}
	
	for( int i=1 ; i<=w ; i++ ) cout << x[i] << endl ;
	
return 0;
}