Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	lines, _ := strconv.Atoi(sc.Text())
	l := make([]int, lines)
	for i := 0; i < lines; i++ {
		l[i] = i + 1
	}

	sc.Scan()
	rows, _ := strconv.Atoi(sc.Text())
	for i := 0; i < rows; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), ",")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])

		l[a-1], l[b-1] = l[b-1], l[a-1]
	}
	for _, j := range l {
		fmt.Println(j)
	}
}

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;
}

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

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

C++: #include <cstdio>

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 <iostream>
#include <vector>

using namespace std;

int main(){
    int w, n, a, b;
    vector<pair<int, int>> h_lines;
    cin >> w >> n;
    vector<int> res(w+1);
    while(scanf("%d,%d",&a,&b)+1){
     h_lines.push_back(pair<int, int>(a,b));   
    }
    
    
    for (int i = 1; i <= w; ++i){
        int where = i;
        for (auto line:h_lines){
            if (line.first == where){
                where = line.second;
            } else if (line.second == where){
                where = line.first;
            }
        }
        res[where] = i;
    }
    
    for (auto itr = res.begin()+1; itr != res.end(); ++itr){cout << *itr << "\n";}
    
 return 0;   
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long

signed main(){
        //int a;
        //while( scanf("%lld", &a) != EOF ){}

        int w;
        scanf("%lld",&w);
        vector<int> line(w);
        for(int i=0;i<w;i++){
                line[i] = i;
        }

        int n;
        scanf("%lld",&n);
        for(int i=0;i<n;i++){
        int a,b;
        scanf("%lld,%lld",&a,&b);
        int t = line[a-1];
        line[a-1] = line[b-1];
        line[b-1] = t;
        }

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


        return 0;
}

C++: #include<stdio.h>

int main(){
        int W,N;
        int w[30];

        scanf("%d",&W);
        scanf("%d",&N);

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

        int a,b,dm;
        for(int i=0;i<N;i++){
                scanf("%d,%d",&a,&b);

                //swap(w[a-1],w[b-1]
                dm = w[a-1];
                w[a-1]=w[b-1];
                w[b-1]=dm;
        }

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

        return 0;
}

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

int main()
{
	int n,i;
	cin>>n;
	int*p;
	p=new int[n];  
	for(i=0;i<n;i++)
    *(p+i)=i+1;
    
    int x,y,temp,k;
    cin>>k;
    for(i=0;i<k;i++)
    {	
    	scanf("%d,%d",&x,&y	);
    	temp=*(p+x-1);
    	*(p+x-1)=*(p+y-1);
    	*(p+y-1)=temp;
    }
    for(i=0;i<n;i++)
    	cout<<*(p+i)<<endl;
    
	delete []p;
	return 0;
}