Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

C++: // includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int w, n;
  cin >> w >> n;
  vector<int> vec = vector<int>(w, 0);
  rep(i, w){
    vec[i] = i;
  }
  rep(i, n){
    string s;
    cin >> s;
    int a, b;
    rep(j, s.size()){
      if(s[j] == ','){
        a = stoi(s.substr(0, j));
        b = stoi(s.substr(j+1, -1));
        break;
      }
    }
    a--; b--;
    swap(vec[a], vec[b]);
  }
  rep(i, w){
    cout << vec[i] + 1 << endl;
  }
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
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 w,n;
  cin>>w>>n;
  vector<int> row(w);
  rep(i,w)row[i]=i+1;
  rep(i,n){
    int a,b;
    scanf("%d,%d",&a,&b);
    swap(row[--a],row[--b]);
  }
  rep(i,w)
    cout<<row[i]<<endl;


}

C++: #include <stdio.h>

int main()
{
	int a[50];
	int n,w;
	int x,y;
	int dummy;
	while(scanf("%d", &n) != EOF){
		scanf("%d", &w);
		for(int i = 1; i <= n; i++){
			a[i] = i;
		}
		for(int i = 0; i < w; i++){
			scanf("%d,%d", &x, &y);
			dummy = a[y];
			a[y] = a[x];
			a[x] = dummy;
		}
		for(int i = 1; i <= n; i++){
			printf("%d\n", a[i]);
		}
	}
	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 <stdio.h>

int main (void)
{
	int w, i, n, m;
	scanf("%d", &w);
	
	int lot[w];
	for(i=0; i<w; i++)
	{
		lot[i]=i+1;
	}
	scanf("%d", &n);
	int lot_n[2];
	
	for(i=0; i<n; i++)
	{
		scanf("%d,%d", &lot_n[0], &lot_n[1]);
		m=lot[lot_n[0]-1];
		lot[lot_n[0]-1]=lot[lot_n[1]-1];
		lot[lot_n[1]-1]=m;
	}
	
	for(i=0; i<w; i++)
	{
		printf("%d\n", lot[i]);
	}
	return 0;
}

C++: #include<iostream>
int main(){int t[31],w=1,n,a,b;char c;for(;w<31;)t[w]=w++;for(std::cin>>w>>n;n--;t[a]^=t[b]^=t[a]^=t[b])std::cin>>a>>c>>b;for(n=1;n<w+1;)std::cout<<t[n++]<<'\n';}

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 = 0;
  int j2 = 0;
  char q[n];
  for(int i=0;i<w;i++) c[i] = i + 1;
  for(int i=0;i<n;i++){
    cin >> a[i] >> q[n] >> 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<cstdio>
#include<iostream>
using namespace std;
int main(){
    int w,n;
    int np[31];
    scanf("%d",&w);
    scanf("%d",&n);
    int cbef,caft;
    for(int i=0;i<31;i++)
        np[i]=i;
    for(int i=0;i<n;i++){
        int sw;
        char gc;
        scanf("%d%c%d",&cbef,&gc,&caft);
        sw=np[cbef],np[cbef]=np[caft],np[caft]=sw;
    }
    for(int i=1;i<w+1;i++)
        printf("%d\n",np[i]);
    return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>

using namespace std;

typedef long long int lli;

int main() {
	int w, n;
	cin >> w >> n;
	vector<int> ar(w);
	vector<vector<int> > hor(n,vector<int>(2));
	for (int i = 0; i < w; i++) ar[i] += i+1;
	for (int j = 0; j < n;j++) {
		(cin >> hor[j][0]).ignore(1) >> hor[j][1];
		swap(ar[hor[j][0]-1], ar[hor[j][1]-1]);
	}
	for (int i = 0; i < w; i++) cout << ar[i] << endl;
	return 0;
}

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

int main()
{
	int w, n;
	int a[30], b[30];
	
	cin >> w >> n;

	for (int i = 0; i < n; i++) {
		char s;
		cin >> a[i] >> s >> b[i];
	}

	for (int i = 0; i < w; i++) {
		int g = i + 1;

		for (int j = n - 1; j >= 0; j--) {
			if (a[j] == g)
				g = b[j];
			else if (b[j] == g)
				g = a[j];
		}

		cout << g << endl;
	}

	return 0;
}

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

class Amidakuji{

public:
	int W;
	vector<int> array;//????´?1???????????????
	Amidakuji(int w);
	void Swap(int x,int y);
	void call();
};

//????????????????????????????????????
Amidakuji::Amidakuji(int w){

	for (int i = 0; i < w; i++){
		array.push_back(i+1);//[0,1,2,3,4]={1,2,3,4,5}
	}
	
	W = w;

}

void Amidakuji::Swap(int x,int y){

	//???????????£????????????array[]???????????????
	//int?????§???????????£????????§char???int?????????????????????-48;
	
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	

}

void Amidakuji::call(){

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

}

int main(){


	int w, n,loc,a,b;
	string text,str_a,str_b,str_v;

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);

			//????????¶?????§??????10,2??????????????¨??????{1,0,,,2}??????????????¢????????£?????????????????§??????????????????????????????????????????

			//?????????????????????????????????????????????????????§?????????????????£?????????????????\????????????????????£???
			loc=text.find(",", 0);
			str_a = text[0];
			for (int j = 1; j < loc; j++){
				str_v = text[j];
				str_a = str_a + str_v;

			}
			str_b = text[loc + 1];
			for (int j = loc + 2; j < (signed) text.length(); j++){
				str_v = text[j];
				str_b = str_b + str_v;
			}

			
			a = stoi(str_a);
			b = stoi(str_b);


			if (a != 0 && b != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(a, b);
				a = b = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}

	return 0;
}

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

using namespace std;

int main(void) {
    int w, n, a, b;
    scanf("%d%d", &w, &n);
    int x[w];
    for (int i = 0; i < w; i++) x[i] = i + 1;
    for (int i = n; i--;) {
        scanf("%d,%d", &a, &b);
        swap(x[a - 1], x[b - 1]);
    }
    for (int i = 0; i < w; i++) printf("%d\n", x[i]);
    return 0;
}