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

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

C++: #pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
//#define LOCAL



int main(int argc, char * argv[]) 
{
	#ifdef LOCAL
	freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.in", "r", stdin);
	//freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.out", "w", stdout);
	#endif

	int w, n, a[50], f, s;

	while (~scanf("%d", &w))
	{
		for (int i = 1; i <= w; i++)
			a[i] = i;
		scanf("%d", &n);
		while(n--)
		{
			scanf("%d,%d", &f, &s);
			swap(a[f], a[s]);
		}
		for (int i = 1; i <= w; i++)
			printf("%d\n", a[i]);
	}

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int w,n,a,b;
    char c;
    std::deque<int> deq;
    cin >> w;
    for (int i=1;i<w+1;i++) {
        deq[i]=i;
    }
    cin >> n;
    for (int j=0;j<n;j++) {
        cin >> a >> c >> b;
        /*
        int a = x.at(0)-48;
        int b = x.at(2)-48;
        int tmp = deq[b];
        deq[b] = deq[a];
        deq[a] = tmp;*/
        swap(deq[a],deq[b]);
    }
    for (int k=1;k<w+1;k++) {
        cout << deq[k] << endl;
    }
    deq.clear();
}

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

void initilize(int w,int num[]){
	for(int i=0;i<w;i++)
		num[i]=i+1;
}

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

C++: //AOJ Drowng Lots

#include <iostream>
#include <cstdio>
using namespace std;

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

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

void swap(int &a, int &b) {
	a = a ^ b;
	b = a ^ b;
	a = a ^ b;
}

int main() {
	int W, N;
	cin >> W >> N;
	int start[W];
	for (int w = 0; w != W; ++w) {
		start[w] = w+1;
	}

	int a, b, throwaway;

	for (int n = 0; n != N; ++n) {
		cin >> a;
		cin.get();
		cin >> b;
		swap(start[a-1], start[b-1]);
	}

	for (int w = 0; w != W; ++w) {
		cout << start[w] << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n;
int a[1000000];
int sum[1000000];
int main(int argc, char const *argv[])
{

	int tc[30];
	cin>>tc[30];
	int w,v;
	for (int i = 0; i < 30; ++i) tc[i] = i+1;
		for (int i = 0; i < v; ++i)
		{
			int a,b;
			cin>>a>>b;
			int c=tc[a-1];
			tc[a-1]=tc[b-1];
			tc[b-1];

		}
		for (int i = 0; i < strlen(a); ++i)
		
			cout<<t[i]<<endl;
		
		
		
			
		
	    		
}

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

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

C++: #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <queue>
#include <vector>

using namespace std;

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

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


int main()
{
	int w, n, num[31];
	string s;
	cin >> w;
	fill(num, num + 31, 0);
	for (int i = 1; i < w + 1; i++){
		num[i] = i;
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		string l, r;
		int commapos;

		//カンマの左
		for (int i = 0;; i++){
			if (s[i] == ','){
				commapos = i;
				break;
			}
			else{
				l += s[i];
			}
		}

		//カンマの右
		for (int i = commapos + 1; i < (signed)s.length(); i++){
			r += s[i];
		}
		int left = atoi(l.c_str());
		int right = atoi(r.c_str());
		int temp = num[left];
		num[left] = num[right];
		num[right] = temp;
	}
	for (int i = 1; i < w + 1; i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int w, n, a, b, r[30];

int main() {
	scanf("%d %d",&w,&n);
	rep(i,w) r[i] = i+1;
	rep(i,n) {
		scanf("%d,%d",&a,&b);
		swap(r[a-1], r[b-1]);
	}
	rep(i,w) printf("%d\n",r[i]);
}

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

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

C++: #include <iostream>
#include <map>
#include <vector>
#define P pair<int, int>
using namespace std;

int main()
{	
	int w, n;
	cin >> w >> n;
	vector<int> v(w);
	for (int i = 1; i <= w; i++)
		v[i - 1] = i;
	P p;
	int t;
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &p.first, &p.second);
		t = v[p.first - 1];
		v[p.first - 1] = v[p.second - 1];
		v[p.second - 1] = t;
	}
	
	for (int i = 0; i < w; i++)
		cout << v[i] << endl;
	
		
	return 0;
}

C++: #include <iostream>
using namespace std;
int main( void )
{
  int w,n;
  int a[32],b[32],r[32];
  char c;
  cin >> w >> n;
  for( int i=0; i<n; i++ ) cin >> a[i] >> c >> b[i];
  for( int i=1; i<=w; i++ ) {
    int d=i;
    for( int j=n-1; j>=0; j-- ){
      if( a[j] == d ) d = b[j];
      else if( b[j] == d ) d = a[j];
    }
    r[i] = d;
  }
  for( int i=1; i<=w; i++ ) cout << r[i] << endl;
  return 0;
}