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 <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 <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int w, n;
    cin >> w >> n;
    VI a(w);
    REP(i,w) a[i] = i+1;
    while (n--){
        int x, y;
        scanf("%d,%d", &x, &y);
        swap(a[x-1], a[y-1]);
    }
    REP(i,w) cout << a[i] << endl;

    return 0;
}

C++: #include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
void getValues(string& s, int& a, int & b)
{
	string::size_type p = s.find(',');
	string sa = s.substr(0, p);
	string sb = s.substr(p + 1);
	a = atoi(sa.c_str());
	b = atoi(sb.c_str());
}

int main()
{
	int w, n, a, b;
	cin >> w >> n;
	int W[31] = {};
	FOR(i, 1, w + 1) W[i] = i;
	string line;
	while (n--){
		cin >> line;
		getValues(line, a, b);
		swap(W[a], W[b]);
	}
	FOR(i, 1, w + 1) cout << W[i] << "\n";
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    int w,n;
    cin>>w>>n;
    vector<int> act(w);
    for(int c=0;c<act.size();c++) act[c]=c+1;
    for(int c=0;c<n;c++)
    {
        string s;
        cin>>s;
        int a=0,b=0;
        int c2;
        for(c2=0;s[c2]!=',';c2++) {a*=10;a+=s[c2]-'0';}
        c2++;
        for(;c2<s.size();c2++) {b*=10;b+=s[c2]-'0';}

        swap(act[a-1],act[b-1]);
    }
    for(int c=0;c<w;c++) cout<<act[c]<<endl;
}

C++: 
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<stdio.h>
using namespace std;
const int MAX = 100;
int main() {
	int W, N;
	int t[MAX];

	cin >> W >> N;
	for (int i = 0; i < W; i++) {
		t[i] = i;
	}
	for (int i = 0; i < N; i++) {
		int a, b;
		scanf("%d,%d", &a, &b); a--; b--;
		swap(t[a], t[b]);
	}
	for (int i = 0; i < W; i++) {
		printf("%d\n", t[i] + 1);
	}
	return 0;
}

C++: #include <iostream>

const int W_MAX = 30;
const int N_MAX = 30;

int w;
int n;
int a[N_MAX + 1];
int b[N_MAX + 1];
int out[W_MAX + 1];

void chenge(int *farst, int *second){
	int tmp;
	tmp = *farst;
	*farst = *second;
	*second = tmp;
}

int main(void){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	std::cin >> w;
	std::cin >> n;

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

	for(int i = 1; i <= n; i++){
		std::cin >> a[i] >> b[i];
		chenge(&out[a[i]], &out[b[i]]);
	}
	
	for(int i = 1; i <= w; i++){
		std::cout << out[i] << '\n';
	}

	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 = 3;
    for (int i = 0; i < n; ++i) {

    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

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

int main() {
	int w; std::cin >> w;
	int W[w];
	for (int i=0; i<w; i++) W[i] = i+1;
	int n; std::cin >> n;
	int a, b, tmp;
	while (~scanf("%d,%d", &a, &b)) {
		tmp = W[a-1];
		W[a-1] = W[b-1];
		W[b-1] = tmp;
	}
	for (int i=0; i<w; i++) std::cout << W[i] << std::endl;
	return 0;
}

C++: #include<iostream>

int main(){
	int w,n,tate[31],yoko1,yoko2,i,j;
	char c;

	
	std::cin>>w>>n;
	for(i=1;i<=w;i++){
		tate[i]=i;
	}

	for(i=0;i<n;i++){
		std::cin>>yoko1>>c>>yoko2;
		j=tate[yoko1];
		tate[yoko1]=tate[yoko2];
		tate[yoko2]=j;
	}

	for(i=1;i<=w;i++){
		std::cout<<tate[i]<<std::endl;
	}

		
	
	
  return 0;
}

C++: #include <stdio.h>

using namespace std;

int main(){
    int w, n;
    int d[31];
    char s[30];
    while(~scanf("%d %d", &w, &n)){
        for(int i=1;i<=w;i++) d[i] = i;
        for(int i=0;i<n;i++){
            scanf("%s", s);
            int a, b;
            sscanf(s, "%d,%d", &a, &b);
            swap(d[a], d[b]);
        }
        for(int i=1;i<=w;i++) cout << d[i] << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n,m;
  cin>>n>>m;
  int w[30];
  rep(i,n)w[i] = i + 1;
  while(m--){
    int a,b;
    scanf("%d,%d",&a,&b);
    swap(w[--a],w[--b]);
  }
  rep(i,n)cout<<w[i]<<endl;
}

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

int main(){
  int a,b,m[35],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<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	vector<int>v;
	vector<int>::iterator pv=v.begin();
	int w, n;
	scanf("%d,%d", &w, &n);
	for (int i = 0; i < w; i++) {
		v.push_back(i + 1);
	}
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(v[a - 1], v[b - 1]);
	}
	for (int i = 0; i < w; i++) {
		cout << *pv << endl;
		pv++;
	}
	return 0;
}