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 <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  int w, n; cin >> w >> n;
  vector<pair<int, int>> vp(w);
  for (int i = 0; i < w; i++) {
      vp.at(i) = make_pair(i + 1, i + 1);
  }

  for (int i = 0; i < n; i++) {
    int a, b; char c; cin >> a >> c >> b;
    int tmp;
    for (int i = 0; i < w; i++) {
      if (vp.at(i).second == a) {
        vp.at(i).second = b;
        tmp = i;
      }
    }
    for (int i = 0; i < w; i++) {
      if (i == tmp) continue;
      if (vp.at(i).second == b) {
        vp.at(i).second = a;
      }
    }
  }

  for (int i = 0; i < w; i++) {
    swap(vp.at(i).first, vp.at(i).second);
  }

  sort(vp.begin(), vp.end());
  for (int i = 0; i < w; i++) {
    cout << vp.at(i).second << endl;;
  }
}

C++: #include <iostream>

using namespace std;

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

int main(void) {
	int w, n;
	int a, b;
	int value[30];
	char buf[256];
	
	for (int i=0; i<30; i++) {
		value[i] = i+1;
	}
	
	fgets(buf, sizeof(buf), stdin);
	sscanf(buf, "%d", &w);
	fgets(buf, sizeof(buf), stdin);
	sscanf(buf, "%d", &n);
	
	for (int i=0; i<n; i++) {
		fgets(buf, sizeof(buf), stdin);
		sscanf(buf, "%d,%d", &a, &b);
		change2(&value[a-1], &value[b-1]);
	}
	
	for (int i=0; i<w; i++) {
		printf("%d\n", value[i]);
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)

int main(){
    int w, n;
    cin >> w >> n;
    vector<int> num(w, 0);
    int it = 1;
    for(int& k : num) k = it++;
    rep(i, n){
        string a;
        cin >> a;
        swap(num[a[0] - '1'], num[a[2] - '1']);
    }
    for(int k : num)
      cout << k << endl;
    return 0;
}

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

using namespace std;

double dist(double x1, double y1, double x2, double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main(){
	int w, n;

	char bar[10];
	vector<int> a(31);
	const char delim = ',';
	int left, right;

	for(int i = 1; i <= 30; i++){
		a[i] = i;
	}

	cin >> w >> n;

	while(n--){
		cin >> bar;
		left = atoi(strtok(bar, &delim));
		right = atoi(strtok(NULL, &delim));
		swap(a[left], a[right]);
	}

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

	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int n,m,dumy=0,a,b;
	cin>>n>>m;
	int x[n];
	for(int i=0;i<n;i++)
	x[i]=i+1;
	for(int i=0;i<m;i++){
		scanf("%d,%d",&a,&b);
		swap(x[a-1],x[b-1]);
	}
	for(int i=0;i<n;i++)
	cout<<x[i]<<endl;
	return 0;
}

C++: /*
NOTE :
*min_element(.begin(),.end())
*max_element(.begin(),.end())
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define MAX 100
#define INF 1<<20
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;
/////

/////
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  int w; scanf("%d",&w);
  int n; scanf("%d",&n);
  vector<int> T(w);
  REP(i,w) T[i] = i;
  REP(i,n)
  {
    int a, b;
    scanf("%d,%d",&a,&b);
    swap(T[a-1],T[b-1]);
  }
  REP(i,w) cout << T[i]+1 << endl;
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int ans[30];
int main() {
	int w, n; cin >> w >> n;
	vector<P>vec;
	rep(i, n) {
		int a, b; scanf("%d,%d", &a, &b);
		vec.push_back(P(a, b));
	}
	for (int i = 1; i <= w; i++) {
		int pos = i;
		rep(j, vec.size()) {
			if (vec[j].first == pos)pos = vec[j].second;
			else if (vec[j].second == pos)pos = vec[j].first;
		}
		ans[--pos] = i;
	}
	rep(i, w) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

int main(){
	int n,w,ans[31],from,to;
	char com;
	cin>>w>>n;
	for(int i=1;i<=w;i++){
		ans[i]=i;
	}
	for(int i=0;i<n;i++){
		cin>>from>>com>>to;
		int tmp=ans[from];
		ans[from]=ans[to];
		ans[to]=tmp;
	}
	for(int i=1;i<=w;i++){
		cout<<ans[i]<<endl;
	}
    return 0;
}

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

using namespace std;

int main() {
  int W;
  int N;
  int num[30];

  
  cin >> W;
  cin >> N;
  for (int i = 0; i < W; i++) {
    num[i] = i+1;
  }
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a;
    cin.ignore();
    cin >> 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<vector>
#include<utility>
#include<cstdio>

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

C++: #include <iostream>

using namespace std;

int main(){

	int a,b,c;
	int Buffer;
	int VirticalLine[30];
	int HorizonLine[30][2];
	char BB;
			
	
	
	cin>>a>>b;
	
	for(c=0;c<a;c++){
	VirticalLine[c] = c+1;
	}
	for(c=0;c<b;c++){
	cin>>HorizonLine[c][0]>>BB>>HorizonLine[c][1];
	}
	for(c=0;c<b;c++){

		Buffer = VirticalLine[HorizonLine[c][1]-1];
		VirticalLine[HorizonLine[c][1]-1] = VirticalLine[HorizonLine[c][0]-1];
		VirticalLine[HorizonLine[c][0]-1] = Buffer;

	}

	for(c=0;c<a;c++)
	{
	cout<<VirticalLine[c]<<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 ;

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

int main(){
  char c;
  int w,n,a,b,num,ans[5];
  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];
      }
    }
    ans[num-1] = i+1;
  }
  repa(tmp,ans){
    cout << tmp << endl;
  }
  return 0;
}