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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;



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

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

using namespace std;
void swap_my(int &a,int &b){
  int keep = a;
  a = b;
  b = keep;
  
}
int main(){
  int w,n;
  cin >> w >> n;
  vector<int> status(w,0);
  for(int i = 0;i < w;i++){
	status[i] = i;
  }
  for(int i = 0;i < n;i++){
	int a,b;
	scanf("%d,%d",&a,&b);
	swap_my(status[a-1],status[b-1]);
  }
  for(int i = 0;i < w;i++){
	cout << status[i]+1 << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int w,n,a,b,z;
    char q;
    cin>>w>>n;
    vector<int> ans(n);
    for(int i=0;i<w;i++){
        ans[i]=i+1;
    }
    for(int i=0;i<n;i++){
        cin>>a>>q>>b;
        z=ans[a-1];
        ans[a-1]=ans[b-1];
        ans[b-1]=z;
    }
    for(int i=0;i<w;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include<string>
using namespace std;
int main() {
    int line;
    int side;
    int sidenum1,sidenum2;
    int linenum[line];
    char waste;
    cin>>line>>side;
    for(int i=0; i<line; i++){
        linenum[i]=i+1;
    }
    for(int i=0; i<side; i++){
        cin>>sidenum1>>waste>>sidenum2;
        swap(linenum[sidenum1-1],linenum[sidenum2-1]);
    }
    for(int i=0; i<line; i++){
        cout<<linenum[i]<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
#include<cmath>
typedef long long int ll;
#define VI vector<int>

#define rep(i,a) for(int i=0;i<(a);i++)
#define all(i) i.begin(),i.end()
#define INF 1000000000


using namespace std;


/**/
VI y;
pair<int,int> x[31];


int main(){
	int w,n;
	rep(i,31){
		y.push_back(i);
	}
	cin>>w>>n;
	rep(i,n){
		char c;
		cin>>x[i].first>>c>>x[i].second;
		x[i].first--,x[i].second--;
	}
	rep(i,n){
		swap(y[ x[i].first ],y[ x[i].second ]);
	}
	rep(i,w){
		cout<<y[i]+1<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include<cstdio>
using namespace std;
int main (){
	int w,N,d[31],sub;
	int a,b;

	cin>>w>>N;
	for(int j=1;j<=w;j++){
		d[j]=j;
	}
	for(int i=0;i<N;i++){
        scanf("%d,%d",&a,&b);
		sub=d[b];
		d[b]=d[a];
		d[a]=sub;
	}
	for(int k=1;k<=w;k++){
	cout<<d[k]<<endl;
	}

	return 0;
}

C++: #include <iostream>                                           
#include <vector>                                             
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;                                     
  }                                                           
  return 0;                                                   
}

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

int main() {
	int w, n;
	cin >> w >> n;
	int ami[30];
	for (int i = 0; i < w; i++) {
		ami[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		int a, b, temp;
		cin >> a >> b;
		temp = ami[a-1];
		ami[a-1] = ami[b-1];
		ami[b-1] = temp;
	}
	for (int i = 0; i < w; i++) {
	cout << ami[i] <<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
int w, n;
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<iostream>
#include<stdio.h>
#include<vector>
using namespace std;

void Swap(int arr[], int x, int y){
    int temp;
    temp = arr[x];
    arr[x] = arr[y];
    arr[y] = temp;
}

int main(){

    int w, n;
    cin >> w >> n;
    vector<int> arr(w+1);

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

    for(int m=0; m<n; m++){
        int a, b;
        scanf("%d,%d", &a, &b);

        Swap(arr.data(), a, b);
    }

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


    return 0;
}

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

int main()
{
	int w,n;
	vector<int> list;

	cin >> w >> n;

	for(int i=0;i<w;++i)
		list.push_back(i);

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

		a--;
		b--;

		tmp		= list[a];
		list[a]	= list[b];
		list[b]	= tmp;

	}

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

	return 0;
}

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

using namespace std;

int main() {
    int w,n,amida[30],yoko1,yoko2,i;

    cin >> w >> n;

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

    for(i = 0;i < n;i++){
        scanf("%d,%d",&yoko1,&yoko2);
        int box = amida[yoko1];
        amida[yoko1] = amida[yoko2];
        amida[yoko2] = box;
    }

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

C++: #include <cstdio>
#include <iostream>
#include <algorhythm.h>
using namespace std;

int main()
{
  int w,n;
  int c[]={0};
  int a,b;
  //  int temp;

  scanf("%d",&w);
  scanf("%d",&n);

  for(int i=0; i<=n; i++){
    c[i]=i;
  }

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

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

C++: #include <iostream>

using namespace std;


int main(int argc, char const* argv[])
{
	int w,n;
	int a[30],b[30];
	int answer[31];

	cin >> w;

	for( int i = 0;i < 30;i++ ){
		a[i] = b[i] = 0;
		answer[i+1] = 0;
	}

	cin >> n;

	char comma;
	for( int j = 0;j < n;j++ ) cin >> a[j] >> comma >> b[j];

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

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


	return 0;
}