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 <stdlib.h>
using namespace std;

void amida(int w, int n, int a[], int b[]);

int main(void){
  int w, n;
  int a[30], b[30];
  char s[20], tmp[10];

  while(cin >> w){
    cin >> n;
    for(int i = 0; i < n; i++){
      cin >> s;
      int j, k;

      for(j = 0; s[j] != ','; j++){
        tmp[j] = s[j];
      }
      tmp[j++] = 0;
      a[i] = atoi(tmp);

      k = 0;
      while(s[j]){
        tmp[k++] = s[j++];
      }
      tmp[k] = 0;
      b[i] = atoi(tmp);
    }

    amida(w, n, a, b);
  }
}

void amida(int w, int n, int a[], int b[]){
  int ans[31];
  int tmp;

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

  for(int i = 0; i < n; i++){
    tmp = ans[a[i]];
    ans[a[i]] = ans[b[i]];
    ans[b[i]] = tmp;
  }

  for(int i = 1; i <= w; i++){
    cout << ans[i] << "\n";
  }
}

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

int main(){
  int w;
  int n;
  vector<int> vertical;
  int a,b;

  cin>>w;

  for(int i=1;i<=w;++i)
    vertical.push_back(i);

  cin>>n;

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

  for(auto i:vertical)
    cout<<i<<endl;

}

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

using namespace std;
 
int main() {
  int w, n;
  cin >> w >> n;
  int ans[n];
 
  for(int i=0;i<=w;i++)
    ans[i] = i;
    
  for(int i=0;i<n;i++) {
  	
    int a, b;
    cin >> a >> b;
    swap(ans[a], ans[b]);
    
  }
  for (int i=1; i<=w;i++)
    cout << ans[i] << "\n";
    return 0;
}

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

using namespace std;

int main(void){
     int w[30];
     int line;
     int n;
     int a1,b1;
     for(int i = 0;i<30;i++){
	  w[i] = i+1;
     }
     cin >> line;
     cin >> n;
//     for(int i=0;i<line;i++){
//	  cout << w[i] << endl;
//     }
//     cout << endl;

     for(int i=0;i<n;i++){
	  scanf("%d,%d",&a1,&b1);
	  int m = w[a1-1];
	  w[a1-1] = w[b1-1];
	  w[b1-1] = m;
//	  for(int i=0;i<line;i++){
//	       cout << w[i] << endl;
//	  }
//	  cout << endl;
     }

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

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

int main(){
	int w,n;
	cin>>w>>n;
	int a[w];
	for(int i=0;i<w;i++) a[i]=i+1;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int x=s[0]-'1';
		int y=s[2]-'1';
		int z=a[x];
		a[x]=a[y];
		a[y]=z;
	}
	for(int i=0;i<w;i++) cout<<a[i]<<endl;
	return 0;
}

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


int main() {
	int w, n;
	std::cin >> w >> n;
	std::vector<int> vl(w+1);
	for (int i = 1; i < w+1; i++) {
		vl[i] = i;
	}
	for (int j = 0; j < n; j++) {
		int a, b, c;
		std::scanf("%d,%d", &a, &b);
		c = vl[a];
		vl[a] = vl[b];
		vl[b] = c;
	}
	for (int i = 1; i < w + 1; i++) {
		std::cout << vl[i] << std::endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int w;
	int n;
	int y;
	char c;
	int a[35],b[35];
	int x[35];
	cin>>w>>n;
	for(int i=1;i<=w;i++) x[i]=i;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>c>>b[i];
	}
	for(int i=1;i<=n;i++){
		y=x[a[i]];
		x[a[i]]=x[b[i]];
		x[b[i]]=y;
	}
	for(int i=1;i<=w;i++){
		cout<<x[i]<<endl;
	}
}

C++: #include <stdio.h>

void swap(int array[], int a, int b){
	int c;
	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 <stdio.h>
#define MAX 30

int main(void){
    int w,n, tmp;
    int a,b;
    int lot[MAX+1]; // 1-origin

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

    return 0;
}

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

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

C++: #include<stdio.h>

int main(void){
int i,tate,yoko,a,b,temp ;
int array[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30} ;

scanf("%d %d",&tate,&yoko);

for(i=0; i<yoko; i++){
scanf("%d,%d",&a,&b);
a--;//for array index
b--;//for array index
temp = array[a] ;//swap values
array[a] = array[b] ;
array[b] = temp ;
}

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

return 0 ;
}

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];
			if(i==w-1) cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

C++: #include<iostream>

int main(){
		int w,n,i,a[31],y,z,j;
		char x;
		std::cin>>w;
		std::cin>>n;
		for(i=1;i<=w;i++){
			a[i]=i;
		}
		for(i=0;i<n;i++){
			std::cin>>y>>x>>z;
			j=a[y];
			a[y]=a[z];
			a[z]=j;
		}
		for(i=1;i<=w;i++){
		std::cout<<a[i]<<std::endl;
		}


	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int a[31];

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

    for (int i = 1; i <= w; ++i) a[i] = i;

    while (n--) {
        int b, c; scanf("%d,%d", &b, &c);
        swap(a[b], a[c]);
    }

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