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 <stdio.h>

int main()
{
    int w, n, a, b, t, s[30];

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

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

    for (int i = 0; i < w; i++)
        printf("%d\n", s[i]);

    return 0;
}

C++: 
/*
 * main.cpp
 *
 *  Created on: 2011/04/08
 *      Author: satoki
 *      13:05 ~ 6:03
 */
#include <iostream>
#include <string.h>
using namespace std;

int iW;
int iN;
int iA;
int iB;

int iX[31];

void init() {
}

bool input() {
  int i, tmp;
  if (scanf("%d", &iW) == EOF) return false;
  for (i = 0; i <= iW; i++) {
    iX[i] = i;
  }
  scanf("%d", &iN);
  for (i = 0; i < iN; i++) {
    scanf("%d,%d", &iA, &iB);
    tmp = iX[iA];
    iX[iA] = iX[iB];
    iX[iB] = tmp;
  }
  return true;
}

void manage() {
}

int main() {
  int i;
  init();
    input();
    manage();
    for (i = 1; i <= iW; i++) {
      printf("%d\n", iX[i]);
    }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstdio>
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;
		scanf("%d,%d",&HorizonalLine.Left,&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 <vector>
using namespace std;
int main() {
  int w, n;
  while (cin >> w >> n) {
    vector<int> vec;
    for (int i = 0; i < w; ++i) {
      vec.push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
      int a, b;
      scanf("%d,%d", &a, &b);
      a -= 1;
      b -= 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

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

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

C++: #include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(void)
{
  int w=0;
  int n=0;
  int v[50]={};
  int i=0;
  int a=0;
  int b=0;

  for(i=0;i<50;i++)
    v[i]=i+1;

  cin>>w>>n;

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

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

}

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

using namespace std;

int main(void){
	int w,n,*num,a,b,tmp;
	pair<int,int> *ln;
	char nul;

	cin >> w >> n;
	num = new int[w+1];
	ln = new pair<int,int>[n];

	for(int i=0;i<n;i++){
		cin >> a >> nul >> b;
		ln[i]=make_pair(a,b);
	}

	for(int i=1;i<=w;i++){
		tmp=i;
		for(int j=0;j<n;j++)
			tmp=tmp!=ln[j].first?tmp!=ln[j].second?tmp:ln[j].first:ln[j].second;
		num[tmp]=i;
	}
	for(int i=1;i<=w;i++)
		cout << num[i] << endl;

	delete [] ln;
	delete [] num;
	return 0;
}

C++: import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		//Scanner reader=new Scanner(System.in);
		String s=reader.readLine();
		int in=Integer.parseInt(s);
		//int in=reader.nextInt();
		int[] out=new int[in];
		for(int i=1;i<=in;i++)out[i-1]=i;
		//in=reader.nextInt();
		s=reader.readLine();
		in=Integer.parseInt(s);
		for(int i=0;i<in;i++){
			String s1=reader.readLine();
			String[] in1=s1.split(",");
			int a=Integer.parseInt(in1[0]);
			int b=Integer.parseInt(in1[1]);
			int tmp=out[a-1];
			out[a-1]=out[b-1];
			out[b-1]=tmp;
		}
		for(int i=0;i<out.length;i++)System.out.println(out[i]);
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int w, n;
	cin >> w >> n;
	VI a(w);
	rep(i, w)a[i] = i + 1;
	rep(i, n) {
		int x, y;
		scanf("%d,%d", &x, &y);
		swap(a[x - 1], a[y - 1]);
	}
	rep(i, w) cout << a[i] << endl;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	cin>>m>>n;
	vector<int>out(m);
	rep(i,m)out[m]=i+1;
	rep(i,n){
		int a,b;
		char d;
		cin>>a>>d>>b;
		swap(out[a-1],out[b-1]);
	}
	rep(i,m)cout<<out[i]<<endl;

}

C++: #include<iostream>
#include<stdio.h>

using namespace std;


typedef struct{
	int a,b;
}Line;

void Change(int*n, Line*l){
	if(*n==l->a){
		*n = l->b;
	}else if(*n==l->b){
		*n = l->a;
	}
}

int main(){
	
	int w,n;
	Line *l;
	int *bottom;
	int cur;
	
	
	cin>>w;cin>>n;
	
	l=new Line[n];
	bottom=new int[w];
	
	for(int i=0;i<n;++i){
		scanf("%d,%d",&(l[i].a),&(l[i].b));
	}
	
	for(int i=0;i<w;++i){
		cur = i+1;
		
		for(int j=0;j<n;++j){
			Change(&cur,&(l[j]));
		}
		
		bottom[cur-1] = i+1;
	}
	
	for(int i=0;i<w;++i)
		cout<<bottom[i]<<endl;

	return 0;

}