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 <stdio.h>

using namespace std;

int main(){
    int w, n;
    int d[31];
    char s[30];
    while(~scanf("%d %d", &w, &n)){
        for(int i=1;i<=w;i++) d[i] = i;
        for(int i=0;i<n;i++){
            scanf("%s", s);
            int a, b;
            sscanf(s, "%d,%d", &a, &b);
            swap(d[a], d[b]);
        }
        for(int i=1;i<=w;i++) cout << d[i] << endl;
    }
}

C++: #include<iostream>
using namespace std;
 int num[31];
void swap(int a,int b){
  int c = num[a];
  num[a]=num[b];
  num[b]=c;
  

}


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

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

using namespace std;

int main() {

	int i, w, n, a, b, x[31];

	cin >> w;
	cin >> n;
	for(i=1; i<=w; i++) {
		x[i]=i;
	}


	for(i=1; i<=n; i++) {
		scanf("%d,%d", &a, &b);
		int t=x[a];
		x[a]=x[b];
		x[b]=t;
	}

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

	return 0;

}

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

using namespace std;
void lots(int len,int a,int b,int array[]){
    int buffer[5];
    for(int i = 0;i < len; i++){
        if(i == a-1){
            buffer[i] = array[b-1];
        }
        else if(i == b-1){
            buffer[i] = array[a-1];
        }
        else{
            buffer[i] = array[i];
        }
    }
    for(int i = 0; i < len; i++){
        array[i] = buffer[i];
    }

}

int main(){
    int len,duration,a,b;
    cin >> len;
    cin >> duration;
    int array[] = {1,2,3,4,5};
    for(int i = 0; i < duration; i++){
        scanf("%d,%d",&a,&b);
        lots(len,a,b,array);
    }
    for(int i = 0; i < len; i++){
        cout << array[i] << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int w,n,a,b,ans[30];
	cin>>w>>n;
	for(int i=1;i<=w;i++){
		ans[i]=i;
	}
	for(int i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		swap(ans[a],ans[b]);
	}
	for(int i=1;i<=w;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>

using namespace std;

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

C++: #include<stdio.h>
#include<iostream>

using namespace std;


void swap(int* a,int s,int v){
	int c;
	c=a[s];
	a[s]=a[v];
	a[v]=c;
	return;
}

int main(){
	int w,n;
	int ans[100];
	int sw[2];
	
	scanf("%d %d",&w,&n);
	int i;
	for(i=1;i<=w;i++){
		ans[i]=i;
	}
	for(i=0;i<n;i++){
		sw[1]=sw[0]=0;
		scanf("%d,%d",&sw[0],&sw[1]);
		swap(ans,sw[0],sw[1]);
	}
	
	for(i=1;i<=w;i++){
		printf("%d\n",ans[i]);
	}
	
	return 0;
}

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

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

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
long i,ww,n,a,b,w[31],t;
char c;
cin>>ww>>n;
for(i=1;i<=ww;i++)w[i]=i;
for(i=1;i<=n;i++){
cin>>a>>c>>b;
t=w[a];w[a]=w[b];w[b]=t;
}
for(i=1;i<=ww;i++)cout<<w[i]<<endl;
return 0;
}

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

using namespace std;

int main() {
    int lot[31];
    int w,n;
    
    for(int i=1;i<=30;i++){
        lot[i]=i;
    }

    cin>>w>>n;
    for(int i=0;i<n;i++){
        int a,b;
        (cin>>a).ignore()>>b;
        swap(lot[a],lot[b]);
    }
    for(int i=1;i<=w;i++){
        cout<<lot[i]<<endl;
    }
    return 0;
}

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

int main(){
int w = 0;
cin >> w ;
int n = 0;
cin >> n;
int i = 1;
int a[w];
loop(i = 0,i < w,i++){
a[i] = i + 1;
}
loop(i = 1,i <= n,i++){
int aa = 0;int bb = 0;
char split;
cin >> aa >> split >> bb ;
int c = 0;
c = a[aa - 1];
a[aa - 1] = a[bb - 1];
a[bb - 1] = c;
}
loop(i = 0,i < w, i++)
{
cout << a[i] << endl;
}
    return 0;
}

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

using namespace std;

int main()
{
    int ver,hor;
    int a,b;
    int i,tmp;
    char c;
    cin >> ver;
    cin >> hor;

    vector<int> v;
    for(i=0;i<ver;i++)
        v.push_back(i+1);
    for(i=0;i<hor;i++)
    {
        cin >> a >> c >> b;
        tmp = v[a-1];
        v[a-1] = v[b-1];
        v[b-1] = tmp;
    }
    for(i=0;i<ver;i++)
        cout << v[i] << endl;
    cout << endl;
    return 0;
}

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

using namespace std;

int main() {
    int w, n, a, b;
    char com;
    int lot[31];
    
    for(int i=0; i<30; i++){
        lot[i] = i;
    }
    
    cin >> w >> n;
    for(int i=0; i<n; i++){
        cin >> a >> com >> b;
        swap(lot[a], lot[b]);
    }
    for(int i=1; i<=w; i++){
        cout << lot[i] << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int w, n;
	int a[31];
	cin >> w >> n;
	for (int i = 1; i <= w; i++){
		a[i] = i;
	}
	int x, y;
	char t;
	for (int i = 0; i < n; i++){
		cin >> x >> t >> y;
		swap(a[x], a[y]);
	}
	for (int i = 1; i <= w; i++){
		cout << a[i] << endl;
	}
}

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

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

    int *progression = new int[w + 1];
    for (int i = 1; i <= w; ++i) {
        progression[i] = i;
    }

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

        int tmp = progression[a];
        progression[a] = progression[b];
        progression[b] = tmp;
    }

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

    delete[] progression;
}

C++: #include<iostream>
int main(){
	int w,n,a[30][2],b[30];
	std::cin>>w
		>>n;
	for(int i=0;i<n;++i){
		for(int j=0;j<2;++j){
			std::cin>>a[i][j];
		}
	}
	for(int i=1;i<=w;++i){
		b[i]=i;
	}
	for(int i=0;i<n;++i){
			int x=b[a[i][0]];
			b[a[i][0]]=b[a[i][1]];
			b[a[i][1]]=x;
	}
	for(int i=1;i<=w;++i){
		std::cout<<b[i]<<std::endl;
	}
	return 0;
}

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

using namespace std;

void swap(int *var1, int *var2) {
  int tmp = *var1;
  *var1 = *var2;
  *var2 = tmp;
}

int main() {
  int w;
  int n;

  cin >> w;
  cin >> n;

  int vertical_line[w];
  for (int v_i = 0; v_i < w; v_i++)
    vertical_line[v_i] = v_i+1;

  for (int n_i = 0; n_i < n; n_i++) {
    int node1, node2;
    scanf("%d,%d", &node1, &node2);
    swap(vertical_line+node1-1, vertical_line+node2-1);    
  }

  for (int v_i = 0; v_i < w; v_i++)
    cout << vertical_line[v_i] << endl;

  return 0;
}