Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

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