Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

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

int main()
{
	int w, n = 1;
	cin >> w;
	vector<int> vec(w);
	for (auto& x : vec) x = n++;
	cin >> n;
	for (int i = 0; i < n; i++){
		int a, b;
		char c;
		cin >> a >> c >> b;
		int tmp = vec[a - 1];
		vec[a - 1] = vec[b - 1];
		vec[b - 1] = tmp;
	}
	for (auto x : vec) cout << x << "\n";
	cout.flush();
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int main(){
int w;
cin >> w;
char a;
int n;
cin >> n;
int b[n];
int d[n];
int c;
c=0;
while(c<n){
cin >> b[c]>>a>>d[c];
c=c+1;}
int e[w];
c=0;
while(c<w){
e[c]=c;
c=c+1;}
int f;
int g;
c=0;
while(c<n){
f=e[b[c]-1];
g=e[d[c]-1];
e[d[c]-1]=f;
e[b[c]-1]=g;
c=c+1;}
c=0;
while(c<w){
cout << e[c]+1 <<endl;
c=c+1;}
 
 
}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
#include <sstream>

using namespace std;
typedef pair<int,int> P;
vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

int main(){
  int w,n;
  cin>>w;
  cin>>n;
  int ami[40];
  P bou[40];
  for(int i=0;i<n;i++){
    int x=0,y=0;
    scanf("%d,%d",&x,&y);
    bou[i]=P(x,y);
  }
  for (int i=0;i<w;i++){
    int start=i+1;
    for(int j=0;j<n;j++){
      if(bou[j].first==start){start=bou[j].second;}
      else if(bou[j].second==start){start=bou[j].first;}
    }
    ami[start]=i+1;
  }
  for(int i=1;i<=w-1;i++)cout<<ami[i]<<" ";
  cout<<ami[w]<<endl;






}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()

int w,n,ans[32];
pair<int,int> list[32];

int main(){	
	scanf("%d%d",&w,&n);
	rep(i,n){
		int a,b; scanf("%d,%d",&a,&b);
		list[i].first = a;
		list[i].second = b;
	}
	REP(i,1,w+1){
		int cur = i;
		rep(j,n){
			if( list[j].first == cur ){
				cur = list[j].second;
				//printf("i:%d , cur:%d\n",i,cur);
			}else if( list[j].second == cur ){
				cur = list[j].first;
				//printf("i:%d , cur:%d\n",i,cur);
			}
		}
		ans[cur] = i;
	}
	REP(i,1,w+1)printf("%d\n",ans[i]);
	
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

int w,n;
int ans[50];
int a,b;

int main(){
	cin>>w>>n;
	rep(i,w){
		ans[i+1] = i+1;
	}
	rep(i,n){
		char t;
		int tmp;
		cin>>a>>t>>b;
		tmp = ans[a];
		ans[a] = ans[b];
		ans[b] = tmp;
	}
	rep(i,w){
		cout<<ans[i+1]<<endl;
	}
	return 0;
}

C++: w=gets.to_i
n=gets.to_i
a=[*0..w]
n.times{b,c=gets.chomp.split(',').map(&:to_i);a[b],a[c]=a[c],a[b]}
puts a[1..w]

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

int main(){
  string sa,sb;
  int w,n,a,b,c;
  cin>>w>>n;
  int num[w];
  for(int i=0;i<w;i++)
    num[i] = i+1;
  for(;n>0;n--){
    getline(cin,sa,',');
    getline(cin,sb,'\n');
    a = atoi(sa.c_str())-1;
    b = atoi(sb.c_str())-1;
    c = num[a];
    num[a] = num[b];
    num[b] = c;
  }
  for(int i=0;i<w;i++)
    cout << num[i] << endl;
  return 0;
}

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

#define swap(a,b) int c=a;a=b;b=c;

using namespace std;

typedef struct{
    int l;
    int r;
}tint;
int main(){
    
    vector<tint> lines;
    tint ins;
    int w,n;
    int *ans = new int(w+1);
    cin >> w >> n;
    for(int i=0;i<n;i++){
        scanf("%d,%d",&ins.l,&ins.r);
        lines.push_back(ins);
    }
    for(int i=0;i<=w;i++){
        ans[i]=i;
    }
    for(int i=0;i<n;i++){
        swap(ans[lines[i].l],ans[lines[i].r]);
    }

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

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

#define REP(i,n) for(int i=0; i<n; i++)

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

  int lines[w+1];
  REP(i,w+1)
    lines[i] = i;

  REP(i,n){
    int from, to;
    char del;
    cin >> from >> del >> to;
    swap(lines[from], lines[to]);
  }

  for(int i=1; i<w+1; i++)
    cout << lines[i] << endl;

  return 0;
}

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

using namespace std;

int main(){

  int w, n, a, b;

  cin >> w >> n;

  int lot[w];

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

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

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

}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int w, n, a[100], b[100],sw,ap;
	char ch;
	cin >> w >> n;
	for (int i = 1; i <= w; i++) {
		a[i] = i;
	}
	for (int i = 1; i <= n; i++) {
		cin >> sw >> ch >> ap;
		swap(a[sw], a[ap]);
	}
	for (int i = 1; i <= w; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

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