Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	lines, _ := strconv.Atoi(sc.Text())
	l := make([]int, lines)
	for i := 0; i < lines; i++ {
		l[i] = i + 1
	}

	sc.Scan()
	rows, _ := strconv.Atoi(sc.Text())
	for i := 0; i < rows; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), ",")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])

		l[a-1], l[b-1] = l[b-1], l[a-1]
	}
	for _, j := range l {
		fmt.Println(j)
	}
}

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;

}

C++: //
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int w = 0;
    cin >> w;
    
    int n = 0;
    cin >> n;
    
    int c[w];
    for(int i = 0; i < w; i++){
        c[i] = i + 1;
    }
    
    int a, b;
    int buffer;
    for (int i = 0; i < n; i++) {
        scanf("%d,%d",&a, &b);
        //printf("a: %d, b: %d ;; ", a, b);
        //printf("%d, %d -> ", c[a - 1], c[b - 1]);
        buffer = c[a - 1];
        c[a - 1] = c[b - 1];
        c[b - 1] = buffer;
        //printf("%d, %d\n", c[a - 1], c[b - 1]);
    }
    for (int i = 0; i < w; i++) {
        printf("%d\n", c[i]);
    }
    
    
    
    return 0;
}

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

int main() {
  int i, temp;
  int w, n, ai, bi;

  cin >> w;
  cin >> n;

  vector<int> amida;

  // initialize
  for (i = 0; i < w; i++) {
    amida.push_back(i + 1);
  }

  for (i = 0; i < n; i++) {
    scanf("%d,%d", &ai, &bi);

    // swap
    temp = amida.at(ai - 1);
    amida.at(ai - 1) = amida.at(bi - 1);
    amida.at(bi - 1) = temp;
  }

  for (i = 0; i < w; i++) {
    cout << amida.at(i) << endl;
  }

  return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
        int n = 0;
        cin >> n;

        int count = 0;
        cin >> count;

        int i;

        int num[n];

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

        int a,b;
        int temp;

        for(i = 0;i < count;i++)
        {
                scanf("%d,%d",&a,&b);
                temp = num[a-1];
                num[a-1] = num[b-1];
                num[b-1] = temp;
        } 
        for(i = 0;i < n;i++)
        {
                cout << num[i] << endl;
        } 

}