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

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

C++: #include <iostream>

using namespace std;

int main(){
	int w, n;
	cin >> w >> n;
	int s[w];

	for(int i=0; i<w; i++){
		s[i] = i+1;
		while(n--){
		int a, b, c;
		cin >> a >> b;

		int tmp = s[a-1];
		s[a-1] = s[b-1];
		s[b-1] = tmp;
	}

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

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

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int i, temp;
  int w, n, ai, bi;

  cin >> w;
  cin >> n;

  vector<int> amida;

  // initialize
  for (i = 0; i < w; i++) {
    amida.push_back(i + 1);
  }

  for (i = 0; i < n; i++) {
    scanf("%d,%d", &ai, &bi);

    // swap
    temp = amida.at(ai - 1);
    amida.at(ai - 1) = amida.at(bi - 1);
    amida.at(bi - 1) = temp;
  }

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

  return 0;
}

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

int main(){
int a,b,c[60],d[30];
cin >> a;cin >> b;
for(int i = 0;i <= (b - 1);i++){
	scanf("%d,%d",&c[2 * i],&c[2 * i + 1]);
}
for(int e = 1;e <= a;e++){
	d[e - 1] = e;
}
for(int f = 0;f <= b - 1;f++){
	swap(d[c[2 * f] - 1],d[c[2 * f + 1] - 1]);
}
for(int g = 0;g <= a - 1;g++){
	cout << d[g] << endl;
}
fflush(stdin);
getchar();


return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(){
    int w, n;
    int d[31];
    while(cin >> w >> n){
        for(int i=1;i<=w;i++) d[i] = i;
        for(int i=0;i<n;i++){
            string s; cin >> s;
            for(int j=0;j<s.size();j++)
                if(s[j]==',') s[j] = ' ';
            istringstream iss(s);
            int a, b; iss >> a >> b;
            swap(d[a], d[b]);
        }
        for(int i=1;i<=w;i++) cout << d[i] << endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int w,n;
	int a,b;

	cin >> w >> n;

	int h[w];

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

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define INF 2000000000



using namespace std;
int main(void){
    int n,m;
    vector<int> v;
    cin>>n>>m;
    rep(i,0,n){
        v.push_back(i+1);
    }
    
    rep(i,0,m){
        int x,y;
        char c;
        cin>>x>>c>>y;
        x--; y--;
        int swap;
        swap=v[x];
        v[x]=v[y];
        v[y]=swap;
        
    }
    
    rep(i,0,n) cout<<v[i]<<endl;
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <vector>

using namespace std;

void exchange(vector<int> &array, int w, vector<vector <int> > n){

  for(int i=0;i<n.size();i++){
    int a = n[i][0]-1;
    int b = n[i][1]-1;
    //    cout << "a: " << a << ", b: " << b << endl;
    int tmp = array[a];
    array[a] = array[b];
    array[b] = tmp;
  }  
}
  

int main(){

  int w, n;
  cin >> w;
  cin >> n;

  vector<vector <int> > Yoko;
  Yoko.resize(n);
  
  for(int i=0;i<n;i++){
    Yoko[i].resize(2);
    int a, b;
    char c;
    cin >> a >> c >> b;
    Yoko[i][0] = a;
    Yoko[i][1] = b;
  }

  vector<int> array;
  for(int i=0;i<w;i++){
    array.push_back(i+1);
  }
  
  exchange(array, w, Yoko);

  for(int i=0;i<array.size();i++){
    cout << array[i] << endl;
  }
  return 0;
}

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

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

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

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

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

    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;
int w;
int line[30][2];
int perm[31];

int main() {
	cin >> n;
	cin >> w;
	for (int i = 0; i < w; i++) {
		string str;
		cin >> str;
		line[i][0] = str[0] - '0';
		line[i][1] = str[2] - '0';
	}

	for (int i = 1; i <= n; i++) {
		int pt = i;
		for (int j = 0; j < w; j++) {
			if (line[j][0] == pt) pt = line[j][1];
			else if (line[j][1] == pt) pt = line[j][0];
		}
		perm[pt] = i;
	}

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

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

C++: #include<iostream>
#include<stdio.h>
#define N 30
using namespace std;
int main(){
  int w,n,tmp;
  int lod[N]; int lis[N][3];
  while(cin >> n >> w){
  for(int i = 0;i<n;i++){
    lod[i] = i+1;
  }
 
  for(int i=0;i<w;i++){
    scanf("%d,%d",&lis[i][0],&lis[i][2]);
  }
  for(int i=0;i<w;i++){
    tmp = lod[lis[i][0]-1];
    lod[lis[i][0]-1] = lod[lis[i][2]-1];
    lod[lis[i][2]-1] = tmp;
  }
  for(int i=0;i<n;i++){
    cout << lod[i] << endl;
  }
  }
}

C++: #include <iostream>
#include <utility>
using namespace System;
using namespace std;
const int MAX_W = 30;
int main()
{
    int w,n;
	int num[MAX_W+1]={};
	char c;
	cin>>w>>n;
	for(int i=0;i<w;i++){
		num[i]=i+1;
	}
	int a,b;
	for(int i=0;i<n;i++){
		cin>>a>>c>>b;
		swap(num[a-1],num[b-1]);
	}
	for(int i=0;i<w;i++){
		cout<<num[i]<<endl;
	}
    return 0;
}