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>
#define MAX_W 30
#define MAX_N 30
using namespace std;

typedef pair<int, int> P;
P line[MAX_N + 1];
int n, w;
char comma;
int result[MAX_W + 1];

void input()
{
	cin >> w >> n;
	for (int i = 1; i <= n; i++)
		cin >> line[i].first >> comma >> line[i].second;
}

void solve()
{
	int pos;
	for (int i = 1; i <= w; i++)
	{
		pos = i;
		for (int j = 1; j <= n; j++)
		{
			if (line[j].first == pos)
				pos = line[j].second;
			else if (line[j].second == pos)
				pos = line[j].first;
		}
		result[pos] = i;
	}
}

void print()
{
	for (int i = 1; i <= w; i++)
		cout << result[i] << endl;
}

int main()
{
	input();
	solve();
	print();
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int w,n,str[30],fin[30],ans[31],add[31],now=0;
    char stri[7];
    cin>>w>>n;
    for(int i=0;i<n;i++){
        cin>>stri;
        if(stri[3]=='\0'){
            str[i]=stri[0]-'0';
            fin[i]=stri[2]-'0';
        }
        else if(stri[4]=='\0'&&stri[1]==','){
            str[i]=stri[0]-'0';
            fin[i]=(stri[2]-'0')*10+(stri[3]-'0');
        }
        else if(stri[4]=='\0'){
            str[i]=(stri[0]-'0')*10+(stri[1]-'0');
            fin[i]=stri[3]-'0';
        }
        else {
            str[i]=(stri[0]-'0')*10+(stri[1]-'0');
            fin[i]=(stri[3]-'0')*10+(stri[4]-'0');
        }
        add[i]=fin[i]-str[i];
    }
    for(int i=1;i<=w;i++){
        now=i;
        for(int j=0;j<n;j++){
            if(now==str[j])now+=add[j];
            else if(now==fin[j])now-=add[j];
        }
        ans[now]=i;
    }
    for(int i=1;i<=w;i++)cout<<ans[i]<<endl;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int ver, hor;

  cin >> ver;
  cin >> hor;
  int nums[ver];
  for (int i = 0; i < ver; i++)
    nums[i] = i+1;
  
  int tmp, a, b;
  for (int i = 0; i < hor; i++) {
    scanf("%d,%d", &a, &b);
    a--; b--;
    tmp = nums[a];
    nums[a] = nums[b];
    nums[b] = tmp;
  }

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

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

using namespace std;

int horizontalLine,verticalLine;
int A,B;
char UserInput[10];

int main()
{
        cin >> verticalLine;
        cin >> horizontalLine;
        if((verticalLine < 0 || horizontalLine < 0) || (verticalLine > 30 || horizontalLine > 30))
        {
            return 0;

        }

        int NumberExist[verticalLine];
        for(int y = 1; y <= verticalLine; y++)
        {
            NumberExist[y-1] = y;
        }

        for(int x = 1; x <= horizontalLine; x++)
        {
            cin >> UserInput;
            A = UserInput[0] - '0';
            B = UserInput[2] - '0';
            int TempVariable;
            TempVariable = NumberExist[A-1];
            NumberExist[A-1] = NumberExist[B-1];
            NumberExist[B-1] = TempVariable;

        }

        for(int z = 0; z < verticalLine; z++)
        {
            cout << NumberExist[z] << endl;
        }


}

C++: a = (1..gets.to_i).to_a
gets.to_i.times{
	x,y = gets.split(",").map(&:to_i)
	a[x-1], a[y-1] = a[y-1], a[x-1]
}
puts a

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

using namespace std;

void swap(int *var1, int *var2) {
  int tmp = *var1;
  *var1 = *var2;
  *var2 = tmp;
}

int main() {
  int w;
  int n;

  cin >> w;
  cin >> n;

  int vertical_line[w];
  for (int v_i = 0; v_i < w; v_i++)
    vertical_line[v_i] = v_i;

  for (int n_i = 0; n_i < n; n_i++) {
    int node1, node2;
    scanf("%d %d", &node1, &node2);
    swap(vertical_line+node1, vertical_line+node2);    
  }

  for (int v_i = 0; v_i < w; v_i++)
    cout << vertical_line[v_i] << endl;

  return 0;
}

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

struct Line{
  int a,b;
};

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

  vector<Line> h_line(n);
  vector<int> ans(w);

  // input
  for(int i=0,a,b;i<n;++i){
    scanf("%d,%d", &a, &b);
    h_line[i].a = a;
    h_line[i].b = b;
  }

  // solve
  for(int i=1;i<=w;++i){
    int now = i;
    for(int j=0;j<n;++j){
      if(h_line[j].a == now)
        now = h_line[j].b;
      else if(h_line[j].b == now)
        now = h_line[j].a;
    }
    ans[now-1] = i;
  }

  // output answer
  for(int i=0;i<w;++i)
    cout<<ans[i]<<endl;

  return EXIT_SUCCESS;
}

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

int main() {
	int w,n;
	scanf("%d %d",&w,&n);
	int a[n];
	int b[n];
	for(int i=0;i<n;i++){
		scanf("%d,%d",&a[i],&b[i]);
	}
	int ans[w+1];
	for(int i=1;i<=w;i++)ans[i]=i;
	int temp;
	for(int i=0;i<n;i++){
		temp=ans[a[i]];
		ans[a[i]]=ans[b[i]];
		ans[b[i]]=temp;
	}
	for(int i=1;i<=w;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
 
int main(){
 
int w, n;
int num[30]={0};
int a, b;
 
for(int i=0; i<w; i++)
num[i]=i+1;
 
cin>>w;
cin>>n;
 
for(int i=0; i<n; i++){
 
cin>>a>>b;
 
int tmp=num[a];
num[a]=num[b];
num[b]=tmp;
 
 
}
 
 
for(int i=0; i<w; i++)
cout<<num[i]<<"\n";
 
return 0;
 
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>

using namespace std;

const double PI=3.14159265;

int main()
{
	int n,w,a,b,*ans;
	cin>>w>>n;

	ans=new int[w];
	for(int i=0;i<w;i++) ans[i]=i+1;

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

	for(int i=0;i<w;i++) cout<<ans[i]<<endl;

	return 0;

}

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

int main() {

  int w,n;
  cin >> w >> n;

  int num[30];
  for ( int i = 0; i < w; i++ ) {
    num[i] = i;
  }

  for ( int i = 0; i < n; i++ ) {

    int a,b;
    char c;
    cin >> a >> c >> b;
    int k;
    k = num[a-1];
    num[a-1] = num[b-1];
    num[b-1] = k;

  }

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

  return 0;

}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.DL", "r", stdin );
	int w;
	scanf ("%d", &w );
	vector<int> a (w+1, 0 );
	for (int i = 1; i <= w; i++ ) a[i] = i;
	int n;
	scanf ("%d", &n );
	rep (i, n ){
		string s = "";
		cin >> s;
		rep (j, s.length() ){
			if (s[j] == ',' ) s[j] = ' ';
		} // end rep
		stringstream ss (s );
		int b1, b2;
		ss >> b1 >> b2;
		swap (a[b1], a[b2] );
	} // end rep
	for (int i = 1; i <= w; i++ ){
		printf ("%d\n", a[i] );
	} // end for

	return 0;
}