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<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	cin>>m>>n;
	vector<int>out(m);
	rep(i,m)out[i]=i+1;
	rep(i,n){
		int a,b;
		char d;
		cin>>a>>d>>b;
		swap(out[a-1],out[b-1]);
	}
	rep(i,m)cout<<out[i]<<endl;

}

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


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

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 
 using namespace std;
 
 int v[35];
 
 int main()
 {
   int w,n;
   cin>>w>>n;
   for(int i=1;i<=w;i++) v[i]=i;
   while(n--)
   {
     int l,r;
     char temp
     cin>>l>>temp>>r;
     swap(v[l],v[r]);          
   } 
   for(int i=1;i<=w;i++)
   {
     cout<<v[i]<<endl;        
   }
   //while(1);      
   return 0;    
 }

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 
 using namespace std;
 
 int v[35];
 
 int main()
 {
   int w,n;
   cin>>w>>n;
   for(int i=1;i<=w;i++) v[i]=i;
   while(n--)
   {
     int l,r;
     char temp;
     cin>>l>>temp>>r;
     swap(v[l],v[r]);          
   } 
   for(int i=1;i<=w;i++)
   {
     cout<<v[i]<<endl;        
   }
   //while(1);      
   return 0;    
 }

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

int main() {
	int i,n,w,a1,a2,temp;
	char ch;
	
	cin >>w >>n;

	vector<int> amida;
	
	for(i=0;i<w;i++)
		amida.push_back(i+1);
	
	for(i=0;i<n;i++){
		cin >> a1;
		cin >> ch;
		cin >> a2;
		
		temp = amida[a1-1];
		amida[a1-1] = amida[a2-1];
		amida[a2-1] = temp;
		
	}
	
	for(i=0;i<w;i++){
		cout << amida[i] <<endl;
	}	
			
	return 0;
  
}

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

using namespace std;

int main()
{
	int w, n, b, c, p;
	int a[31];

	cin >> w >> n;

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

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

C++: //#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <cmath>
//#include <time.h>

using namespace std;


int main(){

	int w, n;
	int a, b;
	char c;
	vector <int> aa;

	cin >> w;

	for (int i = 0; i < w; i++){
		aa.push_back(i + 1);
	}
	
	cin >> n;

	while (n--){
		cin >> a >> c >> b;
		swap(aa[a - 1], aa[b - 1]);
	}

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


	return 0;
}

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

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

  int w,n;
  scanf("%d %d",&w,&n);
  int left[n];
  int right[n];
  int ans[w+1];
  for(int i=0;i<n;i++) {
    scanf("%d,%d",&left[i],&right[i]);
  }
  for(int i=1;i<=w;i++) {
    int state = i;
    int t = 0;
    while(t<n) {
      if(left[t] == state) {
        state = right[t];
      }
      else if(right[t] == state) {
        state = left[t];
      }
      t++;
    }
    ans[state] = i;
  }
  for(int i=1;i<=w;i++) {
    printf("%d\n",ans[i]);
  }
}

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

int main() {
  int w, n, nx, ny;

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

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

using namespace std;
void lots(int len,int a,int b,int array[]){
    int buffer[5];
    for(int i = 0;i < len; i++){
        if(i == a-1){
            buffer[i] = array[b-1];
        }
        else if(i == b-1){
            buffer[i] = array[a-1];
        }
        else{
            buffer[i] = array[i];
        }
    }
    for(int i = 0; i < len; i++){
        array[i] = buffer[i];
    }

}

int main(){
    int len,duration,a,b;
    cin >> len;
    cin >> duration;
    int array[len];
    for(int i = 0; i < len; i++){
        array[i] = i+1;
    }
    for(int i = 0; i < duration; i++){
        scanf("%d,%d",&a,&b);
        lots(len,a,b,array);
    }
    for(int i = 0; i < len; i++){
        cout << array[i] << endl;
    }
}

C++: #include <stdio.h>

int
main(void)
{
	char line[80];
	int w;
	int n;

	if (fgets(line, sizeof line, stdin) == NULL) {
		return 1;
	}
	if (sscanf(line, "%d", &w) != 1) {
		return 1;
	}

	if (fgets(line, sizeof line, stdin) == NULL) {
		return 1;
	}
	if (sscanf(line, "%d", &n) != 1) {
		return 1;
	}

	int a[n];
	int b[n];

	for (int i = 0; i < n; i++) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			return 1;
		}
		if (sscanf(line, "%d,%d", &(a[i]), &(b[i])) != 2) {
			return 1;
		}
	}

	int r[w];
	for (int i = 1; i <= w; i++) {
		int k = i;
		for (int j = 0; j < n; j++) {
			if (a[j] == k) {
				k = b[j];
			} else if (b[j] == k) {
				k = a[j];
			}
		}
		r[k-1] = i;
	}

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

	return 0;
}

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

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

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

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int w;
	cin >> w;

	vector<int> a;
	for (int i = 0; i < w; i++)
	{
		a.push_back(i + 1);
	}

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int x, y;

		string s;
		cin >> s;

		stringstream ss;
		ss << s;

		ss >> x;
		ss.ignore();
		ss >> y;

		swap(a.at(x - 1), a.at(y - 1));
	}

	for (int i = 0; i < w; i++)
	{
		cout << a.at(i) << endl;
	}
}

C++: #include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#define P pair<int, int>
using namespace std;

int main()
{	
	int w, n;
	cin >> w >> n;
	vector<int> v(w);
	for (int i = 1; i <= w; i++)
		v[i - 1] = i;
	P p;
	int t;
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &p.first, &p.second);
		t = v[p.first - 1];
		v[p.first - 1] = v[p.second - 1];
		v[p.second - 1] = t;
	}
	
	for (int i = 0; i < w; i++)
		cout << v[i] << endl;
	
		
	return 0;
}