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

int main(){
	const int MAX_w = 30;
	int w, n, a, b, c, p;
	int lots[MAX_w + 1];
	string str;
	
	for(int i = 1; i <= MAX_w; i++){
		lots[i] = i;
	}
	
	cin >> w >> n;
	
	for(int i = 0; i < n; i++){
		a = 0; b = 0;
		cin >> str;
		
		p = 0;
		while(str[p] != ','){
			a = a * 10 + (str[p] - 48);
			p++;
		}
		p++;
		while(p < str.size()){
			b = b * 10 + (str[p] - 48);
			p++;
		}
		
		c = lots[a];
		lots[a] = lots[b];
		lots[b] = c;
	}
	
	for(int i = 1; i <= w; i++){
		cout << lots[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 <cstdio>
#include <iostream>
#include <algorhythm>
using namespace std;

int main()
{
  int w,n;
  int c[]={0};
  int a,b;
  //  int temp;

  scanf("%d",&w);
  scanf("%d",&n);

  for(int i=0; i<=n; i++){
    c[i]=i;
  }

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

  for(int i=1; i<=w; i++){
    printf("%d\n",c[i]);
  }
}

C++: 
w = input()
n = input()
k = []
for i in range(w+1):
    k.append(i)
for i in range(n):
    l = raw_input()
    a = int(l[0])
    b = int(l[2])
    temp = k[a]
    k[a] = k[b]
    k[b] = temp

for i in range(w):
    print k[i+1]

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;
    swap(m[d[0]-'0'],m[d[2]-'0']);
  }
  for(int i=1;i<=a;i++)cout<<m[i]<<endl;
  return 0;
}

C++: #include <cstdio>
 #include <algorithm>
 
 int main(){
 	int array[50];
 	int w,n,a,b;
 
 	for(int i=0 ; i<50 ; i++){
 		array[i] = i;
 	}
 	
 	scanf("%d", &w);
 	scanf("%d", &n);
 	for(int i=0 ; i<n ; i++){
 		scanf("%d,%d", &a, &b);
 		swap( array[a] , array[b] );
 	}
 	for(int i=1 ; i<=w ; i++){
 		printf("%d\n", array[i]);
 	}
 }

C++: #include <stdio.h>

int main()
{
int p[31]={0};
int w,n,a,b;
int tmp;
tmp=0;
scanf("%d",&w);scanf("%d",&n);
for(int i=0;i<w;i++)
p[i]=i+1;
for(int i=0;i<n;i++)
{
scanf("%d",&a);scanf("%d",&b);
tmp=p[a-1];p[a-1]=p[b-1];p[b-1]=tmp;

}

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

return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
	int w, n, i, j, m[30][30], a, b, l;
	scanf("%d%d",&w,&n);
	for(i = 0;i < n;i++){
		for(j = 0;j < w;j++){
			m[i][j] = j;
		}
	}
	for(i = 0;i < n;i++){
		scanf("%d%*c%d",&a,&b);
		m[i][b - 1] = a - 1;
		m[i][a - 1] = b - 1;
	}
	for(i = 0;i < w;i++){
		l = i;
		for(j = n - 1;j >= 0;j--){
			l = m[j][l];
		}
		printf("%d\n",l + 1);
	}
	return 0;
}

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

int main() {
	int w, n, x, y;
	string str;
	cin >> w >> n;
	int a[31];
	for (int i = 0; i <= w; i++) {
		a[i] = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> str;
		x = str[0] - 48;
		y = str[2] - 48;
		int tmp = a[x];
		a[x] = a[y];
		a[y] = tmp;
	}
	for (int i = 1; i <= w; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int w,n,num[31];
int main(){
    int a,b;
    cin>>w>>n;
    for(int i=0;i<w;i++)num[i]=i+1;
    for(int i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        swap(num[a-1],num[b-1]);
    }
    for(int i=0;i<w;i++)cout<<num[i]<<endl;
    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	int w, n;
	scanf("%d", &w);
	scanf("%d", &n);
	vector<int> ans;
	REP(i, w)
		ans.push_back(i+1);
	REP(i, n)
	{
		int a,b;
		scanf("%d,%d", &a, &b);
		int temp = ans[a-1];
		ans[a-1] = ans[b-1];
		ans[b-1] = temp;
	}
	REP(i, SZ(ans))
	{
		printf("%d\n", ans[i]);
	}
	return 0;
}

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

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

void initilize(int w,int num[]){
	for(int i=0;i<w;i++)
		num[i]=i+1;
}

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

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;


int main(){

	int i, j;

	int w, n;

	cin >> w;
	cin >> n;

	int S[w];
	int a, b;
	int temp;

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

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

	return 0;
}

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++){
    string s;
    cin>>s;
    vector<string> tmp=split(s,',');
    int x=0,y=0;
    int h=1;
    for(int j=0;j<tmp[0].size()-1;j++)h*=10;
    for(int j=0;j<tmp[0].size();j++){
      x+=(tmp[0][j]-48)*h;
      h/10;
    }
    h=1;
    for(int j=0;j<tmp[1].size()-1;j++)h*=10;
    for(int j=0;j<tmp[1].size();j++){
      y+=(tmp[1][j]-48)*h;
      h/=10;
    }
    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 "bits/stdc++.h"
using namespace std;

int main() {
	int W, N;
	vector<int> V;
	cin >> W >> N;
	for (int i = 1; i <= W; i++) {
		V.push_back(i);
	}
	for (int i = 0; i < N; i++) {
		int A, B;
		char C;
		cin >> A >> C >> B;
		A--, B--;
		swap(V[A], V[B]);
	}
	for (int i = 0; i < W; i++) {
		cout << V[i] << endl;
	}
}