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 <cstdio>
#define SWAP(a,b) {a+=b,b=a-b,a-=b;}

using namespace std;

int W[30];

int main()
{
	int w,n,ai,bi;
	scanf("%d",&w);
	for(int i=0;i<w;++i) W[i]=i+1;
	scanf("%d",&n);
	for(int i=0;i<n;++i) {
		scanf("%d,%d",&ai,&bi);
		SWAP(W[ai-1],W[bi-1]);
	}
	for(int i=0;i<w;++i) { printf("%d\n",W[i]); }
	return 0;
}

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

int main(){
    int w, n;
    cin >> w >> n;
    int ans[w+1];
    rep(i, w+1){
        ans[i] = i;
    }
    rep(i, n){
        int a, b;
        scanf("%d,%d", &a, &b);
        // cin >> a >> b;
        swap(ans[a], ans[b]);
    }
    for (int i = 1; i <= w; i++) {
        cout << ans[i] << endl;
    }
    
    // printf("%d\n", N);
    return 0;
}

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

using namespace std;

void Swap(vector<int>& v, int index1, int index2) {
    int tmp = v[index1];
    v[index1] = v[index2];
    v[index2] = tmp;
}


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

    vector<int> v(w);
    for(int i = 0; i < v.size(); ++i) {
        v[i] = i + 1;
    }
    
    int n;
    cin >> n;

    for(int i = 0, a, b; i < n; ++i) {
        cin >> a;
        cin.ignore();
        cin >> b;

        Swap(v, a - 1, b - 1);
    }

    for(auto x : v) {
        cout << x << '\n';
    }

    return 0;
}

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

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int w, n;
	scanf("%d%d", &w, &n);

	vi line(w);
	rep(i, w) line[i] = i+1;
	rep(i, n){
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(line[a-1], line[b-1]);
	}

	rep(i, w) printf("%d\n", line[i]);

	return 0;
}

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

int main(){
	int w;
	while(cin>>w){
		vector<pair<int, int> > all;
		int n;
		cin>>n;
		for(int i=0; i<n; i++){
			int a, b;
			scanf("%d,%d", &a, &b);
			all.push_back(pair<int, int>(a, b));
		}
		reverse(all.begin(), all.end());
		for(int i=1; i<=w; i++){
			int ima = i;
			for(int j=0; j<n; j++){
				if(all[j].first == ima){
					ima = all[j].second;
				} else if(all[j].second == ima){
					ima = all[j].first;
				}
			}
			cout<<ima<<endl;
		}
	}
}

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

struct THorizonalLine
{
	int Left;
	int Right;
};

int main()
{
	int w;
	cin >> w;
	int n;
	cin >> n;
	vector<int> StartingPoint(w);
	for(int i = 0; i < w; i++){
		StartingPoint[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		THorizonalLine HorizonalLine;
		scanf("%d,%d",&HorizonalLine.Left,&HorizonalLine.Right);
		swap(StartingPoint[HorizonalLine.Left-1], StartingPoint[HorizonalLine.Right-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}

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

int main() {
	int w, n;
	int a[30];
	cin >> w >> n;
	for (int i = 0;i < w;i++) {
		a[i] = i + 1;
	}
	for (int i = 0;i < n;i++) {
		int p, q;
		char s;
		cin >> p >> s >> q;
		swap(a[p - 1], a[q - 1]);
	}
	for (int i = 0;i < w;i++)cout << a[i] << endl;
}

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

int main()
{
	int w, n;
	int a, b;
	
	scanf("%d%d", &w, &n);

	vector<int> num(w + 1);

	for (int i = 1; i <= w; i++){
		num[i] = i;
	}

	for (int i = 0; i < n; i++){
		scanf("%d,%d", &a, &b);
		swap(num[a], num[b]);
	}

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

	return (0);
}

C++: #include <stdio.h>

inline void swap(int array[], int a, int b){
	int c = array[a];
	array[a] = array[b];
	array[b] = c;
}

int main(){
	int array[50];
	int w,n,a,b;

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int w,i,n,l,r;scanf("%d\n%d\n",&w,&n);
    int a[w];
    for(i=0;i<w;i++) a[i] = i+1;
    for(i=0;i<n;i++){
        scanf("%d,%d\n",&l,&r);
        swap(a[l-1],a[r-1]);
    }
    for(i=0;i<w;i++) printf("%d\n",a[i]);
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int w,n,a,b;
	char o;
	cin>>w>>o>>n;
	vector<int>c;
	for(int i=0;i<=w+1;i++)c.push_back(i);
	for(int i=1;i<=n;i++){
	cin>>a>>b;
	swap(c[a],c[b]);
	}
	for(int i=1;i<=w;i++) cout<<c[i]<<endl;
}

C++: #include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

void swap(int& x, int& y) {
  int tmp = x;
  x = y;
  y = tmp;
}

int main() {
  int w, n;
  int ws[30];
  cin >> w;
  REP(i,w-1) { ws[i] = i+1; }
  cin >> n;
  REP(i,n-1) { 
    char dummy;
    int a, b;
    cin >> a;
    cin >> dummy;
    cin >> b;
    swap(ws[a-1], ws[b-1]);
  }
  REP(i,w-1) { cout << ws[i] << 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);
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> 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;
    }
  }
  return 0;
}

C++: #include <iostream>
#include<string>
#include <math.h>
using namespace std;

int main() {
    int num;
    scanf("%d",&num);
    int amida[num+1];
    for(int i = 0;i <= num; i++){
        amida[i] = i;
    }
    
    int bars;
    scanf("%d",&bars);
    int a,b;
    
    for(int i = 0; i < bars;i++){
        (cin>>a).ignore()>>b;
        swap(amida[a], amida[b]);
    }
    
    for(int i = 1; i <= num;i++){
        cout<<amida[i]<<endl;
    }
    return 0;

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[32];
	int i,j,k,n,m;
	char c;
	for(i=0;i<32;i++){
		a[i]=i;
	}
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>j>>c>>k;
		swap(a[j],a[k]);
	}
	for(i=1;i<=n;i++){
		cout<<a[i]<<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);
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.clear();
    cin.ignore();
    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;
    }
  }
  return 0;
}

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

int main(){
  int w, n;
  vector<int> que;
  cin >> w >> n;
  for(int i = 1;i <= w;i++) que.push_back(i);
  for(int i = 0;i < n;i++){
    int a, b;
    scanf("%d,%d", &a, &b);
    swap(que[a-1], que[b-1]);
  }

for(int i = 0;i < w;i++){
  cout << que[i] << "\n";
}
  return 0;
}