Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	n := nextInt()

	numbers := make([]int, w+1)
	for i := 1; i <= w; i++ {
		numbers[i] = i
	}

	for i := 0; i < n; i++ {
		line := nextString()
		words := strings.Split(line, ",")
		a, _ := strconv.Atoi(words[0])
		b, _ := strconv.Atoi(words[1])

		numbers[a], numbers[b] = numbers[b], numbers[a]
	}

	for i := 1; i <= w; i++ {
		fmt.Println(numbers[i])
	}
}

C++: #include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long ull;
typedef long long ll;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

int n,m;
vector<int> vec;
int main()
{
	cin>>n;
	rep(i,n+1)
	{
		vec.pb(i);
	}

	cin>>m;

	rep(i,m)
	{
		int a,b;
		scanf("%d,%d",&a,&b);
		swap(vec[a],vec[b]);
	}
	rep(i,n+1)
	{
		if(!i) continue;
		cout<<vec[i]<<endl;
	}
	


	return 0;
}

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

int main() {
	int w, n;
	cin >> w >> n;
	
	vector<int> v(w);
	for (int i = 0; i < w; i++) {
		v.at(i) = i + 1;
	}

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

		int n = v.at(a - 1);
		v.at(a - 1) = v.at(b - 1);
		v.at(b - 1) = n;
	}

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

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

int main(void){
	int w,n;
	int a,b;
	int line[30];
	int i;
	char comma;

	for(i=0;i<30;i++){
		line[i]=i+1;
	}
	cin >> w;
	if(w<=30&&w>0){
		cin >> n;
		for(i=0;i<n;i++){
			cin >> a >> comma >> b;
			if(a>0&&b>0&&a<=w&&b<=w) swap(line[a-1],line[b-1]);
		}
		for(i=0;i<w;i++){
			cout << line[i] << endl;
		}
	}
	return 0;
}

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>
#include <vector>
#include <string>
using namespace std;
void swap(int &a, int &b){
	int c=a;
	a=b;
	b=c;
}
vector<int> v;

int main(){
	int w, n;
	cin >> w >> n;
	int a[n], b[n];
	string s;
	for(int i=0; i<n; i++){
		cin >> s;
		a[i] = stoi(s);
		while(1){
			if(s[0]!=',') s.erase(s.begin(), s.begin()+1);
			else{
				s.erase(s.begin(), s.begin()+1);
				break;
			}
		}
		b[i] = stoi(s);
	}

	v.resize(w);
	for(int i=0; i<v.size(); i++) v[i]=i+1;
	for(int i=0; i<n; i++){
		swap(v[a[i]-1], v[b[i]-1]);
	}

	for(int i=0; i<n; i++) cout << v[i] << endl;

	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int W, N; cin >> W >> N;
  int a[31], b[31];
  for(int i=0;i<N;++i)
    scanf("%d,%d", &a[i], &b[i]);
  
  int x[31];
  for(int i=1;i<=W;++i){
    int n = i;
    for(int j=0;j<N;++j){
      if(n == a[j])
	n = b[j];
      else if(n == b[j])
	n = a[j];
    }
    x[n] = i;
  }
  for(int i=1;i<=W;++i)
    cout << x[i] << endl;

  return 0;
}

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

void swap(int &a,int &b){
	int tmp;
	tmp = a;
	a = b;
	b = tmp;
}

int main(){
	int w;
	int n;
	char c;
	cin >> w;
	cin >> n;
	int a[n],b[n];
	for(int i=0;i<n;i++)
		cin >> a[i] >> c >> b[i];
	
	int num[w];
	int tmp;
	for(int i=0;i<w;i++)
		num[i] = i+1;
	
	for(int i=0;i<n;i++){
	swap(num[a[i]-1],num[b[i]-1]);
	}
	
	for(int i=0;i<w;i++)
		cout << num[i] <<endl;
}

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

using namespace std;

void Solution()
{
    int w, n;
    
    int temp; //data for swapping
    int a, b;
    char c;
        
    
    cin>>w;
    cin>>n;
    
    vector<int> v;
    
    for(int i = 0; i <= w; i++) // the smallest digit is 1
    {
        v.push_back(i);
    }
    
    for(int i = 0; i < n; i++)
    {
        cin>>a>>c>>b;
        
        temp = v[a]; //swap the position
        v[a] = v[b];
        v[b] = temp;
    }
    
    for(int i=1; i <= w; i++)
    {
        cout<<v[i]<<endl;
    }
}

int main()
{
    Solution();
    return 0;
}

C++: #include <cstdio>
using namespace std;
int main(){
  int *p,i,n,j,a1,b1,buf;
  scanf("%d",&n);
  p=new int[n];
  scanf("%d",&i);
  for(j=0;j<n;j++)p[j]=j+1;
  for(j=0;j<i;j++){
    scanf("%d,%d",&a1,&b1);
    a1--;b1--;
    buf=p[a1];
    p[a1]=p[b1];
    p[b1]=buf;
  }
  for(i=0;i<n;i++)printf("%d\n",p[i]);
}

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

int main(){
    int w, n;
    cin >> w >> n;
    int a, b;
    char com;
    vector<int> r;
    for (int i = 0; i <= w; i++) r.push_back(i);
    
    for (int i = 0; i < n; i++){
	cin >> a >> com >> b;
	swap(r[a], r[b]);
    }

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

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,l,n) for(i=l;i<n;i++)


int main(){
	int i,w,n,a,b,c[35],d;
	char k;

	cin>>w;
	cin>>n;
	//cout<<w<<" "<<n<<endl;
	rep(i,1,w+1){
		c[i]=i;
	}
	rep(i,1,n+1){
		cin>>a>>k>>b;
		//cout<<c[a]<<" "<<c[b]<<endl;
		swap(c[a],c[b]);
		//cout<<c[a]<<" "<<c[b]<<endl<<endl;
		
	}
	rep(i,1,w+1){
		cout<<c[i]<<endl;
	}
	

}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int lot[30],n,m;
  for(int i=0; i<30; i++){lot[i] = i+1;}
  cin>>n>>m;
  while(m--){
    int a,b;
    scanf("%d,%d",&a,&b);
    int c = lot[a-1];
    lot[a-1] = lot[b-1];
    lot[b-1] = c;
  }
  for(int i=0; i<n; i++){cout<<lot[i]<<endl;}
  return 0;
}

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

int main() {
	int w, n, a, b;
	char comma;
	vector<int> amida;
	cin >> w >> n;
	for (int i = 0;i < w;i++) amida.push_back(i + 1);

	for (int i = 0;i < n;i++) {
		cin >> a >> comma >> b;
		swap(amida.at(a - 1), amida.at(b - 1));
	}

	for (int i = 0;i < w;i++) {
		cout << amida.at(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(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;
    }
  }
  return 0;
}