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>

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;
	inst_lot=new 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();
	
	delete inst_lot;
	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;

#define DATA_MAX 50

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

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

	int data[DATA_MAX];

	cin >> w;
	cin >> n;

	for( int i = 0 ; i < DATA_MAX ; i++ )
	{
		data[i] = i+1;
	}

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

	return 0;
}

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

	temp = a;
	a = b;
	b = temp;

	return;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef vector<int> vi;

int w,n,a,b;

int main() {
	scanf("%d", &w);
	vi v(w);
	rep(i,w) v[i] = i+1;

	scanf("%d", &n);
	rep(i,n) {
		scanf("%d,%d", &a, &b);
		swap(v[a-1], v[b-1]);
	}

	rep(i,w) printf("%d\n", v[i]);
}

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

using namespace std;

int w;//縦本の総本数
int n;//横棒の数
int D[30];//あみだの並び順


queue<pair<int,int> > que;
int a,b;
int temp;

int main(){
  scanf("%d %d",&w,&n);
  for(int i = 1;i <= w;i++){
    D[i] = i;
  }//あみだを初期化
  for(int i = 0;i < n;i++){
    scanf("%d,%d",&a,&b);
    que.push(pair<int,int>(a,b));
  }
  for(int i = 0;i <n;i++){
    a =que.front().first;
    b =que.front().second;
    temp = D[b];
    D[b] = D[a];
    D[a] = temp;
    que.pop();
  }
  for(int i = 1;i <=w;i++){
    printf("%d\n",D[i]);
  }

}

C++: #include<iostream>
#include<stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

void swap(int& x, int& y) {
  int tmp = x;
  x = y;
  y = tmp;
}

int main() {
  int w, n;
  int ws[30];
  cin >> w;
  REP(i,w) { ws[i] = i+1; }
  cin >> n;
  REP(i,n) { 
    string s;
    int a, b;
    cin>>s;
    a=atoi((s.substr(0,s.find(","))).c_str());
    b=atoi((s.substr(s.find(",")+1)).c_str());
    swap(ws[a-1], ws[b-1]);
  }
  REP(i,w) { cout << ws[i] << endl; }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int main(){
  int n,m;
  cin >>n>>m;
  vector<int> lot;
  for(int i=0; i<n; i++) lot.push_back(i+1);
  for(int i=0,a,b,c; i<m; i++){
    scanf("%d,%d",&a,&b);
    c = lot[a-1];
    lot[a-1] = lot[b-1];
    lot[b-1] = c;
  }
  for(int i=0; i<n; i++) cout <<lot[i]<<endl;
  return 0;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

//typedef int kz;
//typedef long kz;
typedef long long kz;

kz gcd(kz a,kz b) { if(b==0) return a; else gcd(b,a%b); }
kz lcm(kz a,kz b) { return a*b/gcd(a,b); }

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/


int main(){
    int mod=1000000007;
    int n,w;
    scanf("%d",&w);
    scanf("%d",&n);
    int x[w];
    int r[n][2];
    int ans[w];

    for (int i=0;i<n;i++) {
        scanf("%d,%d",&r[i][0],&r[i][1]);
    }
    for (int i=1;i<=w;i++) {
        int tmp=i;
        for (int j=0;j<n;j++) {
            if (tmp==r[j][0]) tmp=r[j][1];
            else if (tmp==r[j][1]) tmp=r[j][0];
        }
        ans[tmp-1]=i;
    }
    for (int i=0;i<w;i++) {
        printf("%d\n",ans[i]);
    }
    return 0;
}

C++: #include<stdio.h>

int main(){
int tate,yoko,bou[30][2],j,x,kekka[]={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,31},i=0;
scanf("%d %d",&tate,&yoko);
for(j=0;j<yoko;j++){
scanf("%d , %d",&bou[j][1],&bou[j][2]);
}
for(i=1;i<tate+1;i++){
x=i;
for(j=0;j<yoko;j++){
if(bou[j][1]==x){
x=bou[j][2];
}
else if(bou[j][2]==x){
x=bou[j][1];
}
}
kekka[x-1]=i;
}
for(j=0;j<tate;j++){
printf("%d\n",kekka[j]);
}
}

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

struct THorizonalLine
{
	int Left;
	int Right;
};

int main()
{
	int w;
	cin >> w;
	int n;
	cin >> n;
	vector<int> StartingPoint(w);
	for(int i = 0; i < w; i++){
		StartingPoint[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		THorizonalLine HorizonalLine;
		char Dummy;
		cin >> HorizonalLine.Left >> Dummy >> HorizonalLine.Right;
		swap(StartingPoint[HorizonalLine.Left-1], StartingPoint[HorizonalLine.Right-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}

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

int main(void){
	int w,n;
	int a,b;
	int line[30];
	int i;

	for(i=0;i<30;i++){
		line[i]=i+1;
	}
	cin >> w;
	if(w<=30&&w>0){
		cin >> n;
		for(i=0;i<n;i++){
			cin >> a >> b;
			if(a>0&&b>0&&a<=w&&b<=w) swap(line[a-1],line[b-1]);
		}
		for(i=0;i<w;i++){
			cout << line[i];
			if(i==w-1) cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;

int main(){
	int w;
	int n;
	while(cin>>w>>n){
	vector<int> x(w);
	for(int i=0;i<w;i++)x[i]=i+1;

	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int a=s[0]-'0';
		int b=s[2]-'0';
		a--;
		b--;
		int tmp=x[a];
		x[a]=x[b];
		x[b]=tmp;
	}
	for(int i=0;i<w;i++)cout<<x[i]<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
int array[31];

void swap(int a, int b) {
  int c = array[a];
  array[a] = array[b];
  array[b] = c;
}

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