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>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int arr[32];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int w, n;
    cin >> w >> n;
    for (int i = 1; i <= 30; ++i)
        arr[i] = i;

    for (int i = 1; i <= n; ++i)
    {
        int a, b;
        char c;
        cin >> a >> c >> b;
        //cout << a << " " << b << endl;
        swap(arr[a], arr[b]);
    }

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

    return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
  int num,change,x,y;
  cin>>num;
  cin>>change;
  char c;
  int *now=new int[num+1]; 
  now[0]=0;
  for(int i=1;i<=num;i++) 
    now[i]=i;
  for(int i=0;i<change;i++) {
    cin>>x>>c>>y;
    int tmp=now[x];
    now[x]=now[y];
    now[y]=tmp;
  }
  for(int i=1;i<=num;i++)
    cout<<now[i]<<endl;
  return 0;
}

C++: #include<stdio.h>
int main(void){
	int w,n,x,y,temp;
	int a[31];
	char str[7];
	for(int i = 0; i < 31; i++){
		a[i] = i;
	}
	scanf("%d %d",&w,&n);
	for(int i = 0; i < n; i++){
		gets(str,6);
		if(str[3] == ',')
			str[3] = ' ';
		else
			str[2] = ' ';
		sscanf(str,"%d %d",&x,&y);
		temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

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

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

C++: #include <iostream>

using namespace std;

int main(){
    int w,n;
    int lots[30];

    cin>>w;
    for (int i=0;i<w;i++){
        lots[i]=i+1;
    }
    cin>>n;
    for (int i = 0; i < n; ++i) {
        int a,b;

        scanf("%d,%d",&a,&b);
        swap(lots[a-1],lots[b-1]);
    }
    for (int j = 0; j < w; ++j) {
        cout<<lots[j]<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for (int i=n;^i;i--)
#define ALL(v) v.begin(),v.end()
// #define int ll 
#define eps 1e-9
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
typedef long long ll;

signed main(void){
	int a[30];
	int w,n;
	scanf("%d %d",&w,&n);
	rep(i,w) a[i]=i;
	rep(i,n) {
		int sa,sb;
		scanf("%d,%d",&sa,&sb);
		swap(a[sa-1],a[sb-1]);
	}
	rep(i,w) printf("%d\n",a[i]+1);
}

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

#define MAX 30
#define rep(i, a) for(int i = 0; i < (a); ++i)
#define rept(i, a, b) for(int i = (a); i <= (b); ++i)

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

C++: #include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    // default
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.ignore(INT_MAX, '\n');
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_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;
    }
  } // while loop out
  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;
	}														//1 = 49
	for (int i = 0; i < n; i++) {
		cin >> str;
		x = stoi(str);
		if (to_string(x).size()==1&&str.size()==3){
			int temp = str[2];
			y = temp-48;
		}
		else if(to_string(x).size()==2&&str.size()==4){
			int temp = str[3];
			y = temp - 48;
		}
		else if(to_string(x).size()==1&&str.size()==4){
			int juunokurai = str[2];
			int itinokurai = str[3];
			y = (juunokurai - 48) * 10 + (itinokurai - 48);
		}
		else {
			int juunokurai = str[3];
			int itinokurai = str[4];
			y = (juunokurai - 48) * 10 + (itinokurai - 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 <string>
#include <stdlib.h>
using namespace std;

int main() {
  int w,n,a1,b1,change;
  int num[40];
  string str;
  cin >> w;
  for(int i=1;i<w+1;i++) {
    num[i] = i;
  }
  cin >> n;
  for(int i=1;i<n+1;i++) {
    cin >> str;
    a1 = strtol(str.substr(0).c_str(),NULL,0);
    b1 = strtol(str.substr(2).c_str(),NULL,0);
    change = num[a1];
    num[a1] = num[b1];
    num[b1] = change;
  }
  for(int i=1;i<w+1;i++) {
    cout << num[i] << endl;
  }
}

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

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

int main()
{
  int w, n, i;
  cin >> w >> n;
  int num[w + 1], a[n + 1], b[n + 1];

  REP(i, w) num[i] = i + 1;
  REP(i, n) scanf("%d,%d" ,&a[i], &b[i]);
  REP(i, n) swap(num[a[i] - 1], num[b[i] - 1]);
  REP(i, w) cout << num[i] << endl;
}

C++: #include <stdio.h>

int main(void) {
  int i, n, j, k, w;
  scanf("%d%d", &w, &n);
  int a[n], b[n], now, ans[w + 2];
  for(i = 0; i < n; ++i) scanf("%d,%d", &a[i], &b[i]);
  for(i = 1; i <= w; ++i) {
    now = i;
    for(j = 0; j < n; ++j) {
      if(a[j] == now) now = b[j];
      else if(b[j] == now) now = a[j];
    }
    ans[now] = i;
  }
  for(i = 1; i <= w; ++i) printf("%d\n", ans[i]);
  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
#define F(I,J,N) for(int I=J;I<N;I++)

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

int main(){
	int *l;
	int p,q;
	int x,y;
	while(cin>>p){
		l=new int[p];
		F(i,0,p) l[i]=i+1;
		cin>>q;
		F(i,0,q){
			scanf("%d,%d",&x,&y);
			swap(&l[x-1],&l[y-1]);
		}
		F(i,0,p) cout<<l[i]<<endl;
		delete []l;
	}
}

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

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

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


int main()
{
	int w, n, A, B;
	int a[30], b[30][2];
	cin >> w >> n;
	for (int i = 0;i < w; i++) {
		a[i] = i + 1;
	}
	for (int j = 0;j < n;j++) {
		scanf("%d,%d", &b[j][0], &b[j][1]);
		A = a[b[j][0]-1], B = a[b[j][1]-1];
		a[b[j][0]-1] = B, a[b[j][1]-1] = A;
	}
	for (int k = 0;k < w;k++) {
		cout << a[k] << endl;
	}

    return 0;
}