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 <cstdio>
using namespace std;

void swap(int *a, int *b){
    int temp = *a;
    *a = *b;
    *b = temp;
}

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

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>

#define EPS (1e-8)

using namespace std;

int main() {
  int w, n;
  while(cin >> w >> n, w) {
    int a[n][2];
    int r[w];
    int t;
    for (int i = 0; i < n; i++) {
      cin >> a[i][0];
      cin.ignore();
      cin >> a[i][1];
    }
    for (int i = 0; i < w; i++) {
      r[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
      t = r[a[i][1] - 1];
      r[a[i][1] - 1] = r[a[i][0] - 1];
      r[a[i][0] - 1] = t;
    }
    for (int i = 0; i < w; i++) {
      cout << r[i] << endl;
    }
    w = 0;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;

#define PI (3.1415926535)
#define EPS (1e-10)
bool eq(double a, double b){
  return abs(a-b) < EPS;
}

int main(){
  int w,n;
  scanf("%d%d",&n,&w);
  int a[n];
  REP(i,n) a[i] = i;
  REP(i,w){
    int b,c;
    scanf("%d,%d",&b,&c);
    swap(a[b-1],a[c-1]);
  }
  REP(i,n) printf("%d\n",a[i]+1);
  
  return 0;
}

C++: #include<iostream>
#include"Header.h"
using namespace std;
#define size_n 4
#define size_num 30

int main(){
	int swap_times;
	int num_length;
	char n[size_n]={'\0'};
	int num[size_num] = {0};
	int temp;
	cin >> num_length;
	cin >> swap_times;

	for(int i=1;i <= num_length;i++){
		num[i] = i;
	}

	for(int i=1;i<=swap_times;i++){
		cin >> n;
		temp					= num[(int)n[0]-(int)'0'];
		num[(int)n[0]-(int)'0'] = num[(int)n[2]-(int)'0'];
		num[(int)n[2]-(int)'0'] = temp;

		//データの初期化
		for(int i=0;i<size_n;i++){
			n[i] = '\0';
		}
	}

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

	return 0;
}

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

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

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

int c[32] = {0};

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

    return 0;
}

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

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

int main(void) {
    int select; scanf("%d", &select);
    int amida[select + 1];
    for(int r = 1; r <= select; r++) amida[r] = r;
    int horizon; scanf("%d", &horizon);
    for(int r = 0; r < horizon; r++) {
        int x, y; scanf("%d,%d", &x, &y);
        swap(amida[x], amida[y]);
    }
    for(int r = 1; r <= select; r++)cout << amida[r] << endl;
    return(0);
}

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

int main(){
  int a,b,m[31],c,e;
  string d;
  cin >>a>>b;
  for(int i=1;i<=a;i++)m[i]=i;
  for(int i=1;i<=b;i++){
    cin >>d;
    cout <<d[0]<<d[1]<<d[2]<<endl;///////
    swap(m[d[0]-'0'],m[d[2]-'0']);
  }
  for(int i=1;i<=a;i++)cout<<m[i]<<endl;
  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(void){
    int w[30],a,b,tmp,d,n;
    char c;
    cin >> d >> n;
    for(int i=0; i<d; i++)
        w[i] = i+1;
    for(int i=0; i<n; i++){
        cin >> a >> c >> b;
        tmp = w[a-1]; w[a-1] = w[b-1]; w[b-1] = tmp;
    }
    for(int i=0; i<d; i++)
        cout << w[i] << endl;
}

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

void swap(int *a, int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

int main(){

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

  int list[40];
  for(int i = 0; i < 40 ; i++){
    list[i] = i;
  }

   int a,b;
   char tmp;
   while( cin >> a >> tmp >> b ){
    swap( &list[a], &list[b] );
  }
  
  for(int  i = 1; i <= w ; i++ ){
    cout << list[i] << endl;
  }
  
  return 0;
}

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

int main(){
	int amida[30];
	for (int i = 0; i < 30; i++){
		amida[i] = i + 1;
	}
	int n, w;
	int a, b;

	cin >> w;
	cin >> n;
	int c;
	for (int i = 0; i < n; i++){
		char c;
		cin >> a >> c >> b;
		swap(amida[a - 1], amida[b - 1]);
	}
	for (int i = 0; i < w; i++){
		cout << amida[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;

const int IMAX = ((1<<30)-1)*2+1 ;
const int INF = 100000000;
double EPS = 1e-10 ;

int main(){
  char c;
  int w,n,a,b,num ;
  bool flag = true;
  cin >> w >> n;
  vi v(w,0),va,vb ;
  rep(i,n){
    cin >> a >> c >> b ;
    va.pb(a),vb.pb(b) ;
  }

  rep(i,w){
    num = i+1 ;
    rep(j,n){
      if(num == va[j]){
        num = vb[j];
      }
      else if(num == vb[j]){
        num = va[j];
      }
    }
    v[num-1] = i+1;
  }
  for(int i = 0;i < v.size();++i){
    cout << v[i] << endl;
  }
  return 0;
}

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

int main(int argc, const char * argv[]) {
    std::vector<int> r;
    int w,n;
    int a,b;
    std::cin >> w >> n;
    for(int i = 0;i <= w;i++){
        r.push_back(i);
    }
    for(int i = 0; i <= n; i++){
        (std::cin >> a).ignore()>>b;
        std::swap(r[a],r[b]);
    }
    for(int i = 0; i <=w;i++){
        std::cout<< r[i] << std::endl;
        
    }
}