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++: import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		//Scanner reader=new Scanner(System.in);
		String s=reader.readLine();
		int in=Integer.parseInt(s);
		//int in=reader.nextInt();
		int[] out=new int[in];
		for(int i=1;i<=in;i++)out[i-1]=i;
		//in=reader.nextInt();
		s=reader.readLine();
		in=Integer.parseInt(s);
		for(int i=0;i<in;i++){
			String s1=reader.readLine();
			String[] in1=s1.split(",");
			int a=Integer.parseInt(in1[0]);
			int b=Integer.parseInt(in1[1]);
			int tmp=out[a-1];
			out[a-1]=out[b-1];
			out[b-1]=tmp;
		}
		for(int i=0;i<out.length;i++)System.out.println(out[i]);
	}
}

C++: // includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int w, n;
  cin >> w >> n;
  vector<int> vec = vector<int>(w, 0);
  rep(i, w){
    vec[i] = i;
  }
  rep(i, n){
    string s;
    cin >> s;
    int a, b;
    rep(j, s.size()){
      if(s[j] == ','){
        a = stoi(s.substr(0, j));
        b = stoi(s.substr(j+1, -1));
        break;
      }
    }
    a--; b--;
    swap(vec[a], vec[b]);
  }
  rep(i, w){
    cout << vec[i] + 1 << endl;
  }
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int w,n;
  cin>>w>>n;
  vector<int> row(w);
  rep(i,w)row[i]=i+1;
  rep(i,n){
    int a,b;
    scanf("%d,%d",&a,&b);
    swap(row[--a],row[--b]);
  }
  rep(i,w)
    cout<<row[i]<<endl;


}

C++: #include <stdio.h>

int main()
{
	int a[50];
	int n,w;
	int x,y;
	int dummy;
	while(scanf("%d", &n) != EOF){
		scanf("%d", &w);
		for(int i = 1; i <= n; i++){
			a[i] = i;
		}
		for(int i = 0; i < w; i++){
			scanf("%d,%d", &x, &y);
			dummy = a[y];
			a[y] = a[x];
			a[x] = dummy;
		}
		for(int i = 1; i <= n; i++){
			printf("%d\n", a[i]);
		}
	}
	return 0;
}

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

int main (void)
{
	int w, i, n, m;
	scanf("%d", &w);
	
	int lot[w];
	for(i=0; i<w; i++)
	{
		lot[i]=i+1;
	}
	scanf("%d", &n);
	int lot_n[2];
	
	for(i=0; i<n; i++)
	{
		scanf("%d,%d", &lot_n[0], &lot_n[1]);
		m=lot[lot_n[0]-1];
		lot[lot_n[0]-1]=lot[lot_n[1]-1];
		lot[lot_n[1]-1]=m;
	}
	
	for(i=0; i<w; i++)
	{
		printf("%d\n", lot[i]);
	}
	return 0;
}

C++: #include<iostream>
int main(){int t[31],w=1,n,a,b;char c;for(;w<31;)t[w]=w++;for(std::cin>>w>>n;n--;t[a]^=t[b]^=t[a]^=t[b])std::cin>>a>>c>>b;for(n=1;n<w+1;)std::cout<<t[n++]<<'\n';}

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

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(){
    int w,n;
    int np[31];
    scanf("%d",&w);
    scanf("%d",&n);
    int cbef,caft;
    for(int i=0;i<31;i++)
        np[i]=i;
    for(int i=0;i<n;i++){
        int sw;
        char gc;
        scanf("%d%c%d",&cbef,&gc,&caft);
        sw=np[cbef],np[cbef]=np[caft],np[caft]=sw;
    }
    for(int i=1;i<w+1;i++)
        printf("%d\n",np[i]);
    return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>

using namespace std;

typedef long long int lli;

int main() {
	int w, n;
	cin >> w >> n;
	vector<int> ar(w);
	vector<vector<int> > hor(n,vector<int>(2));
	for (int i = 0; i < w; i++) ar[i] += i+1;
	for (int j = 0; j < n;j++) {
		(cin >> hor[j][0]).ignore(1) >> hor[j][1];
		swap(ar[hor[j][0]-1], ar[hor[j][1]-1]);
	}
	for (int i = 0; i < w; i++) cout << ar[i] << endl;
	return 0;
}

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

int main()
{
	int w, n;
	int a[30], b[30];
	
	cin >> w >> n;

	for (int i = 0; i < n; i++) {
		char s;
		cin >> a[i] >> s >> b[i];
	}

	for (int i = 0; i < w; i++) {
		int g = i + 1;

		for (int j = n - 1; j >= 0; j--) {
			if (a[j] == g)
				g = b[j];
			else if (b[j] == g)
				g = a[j];
		}

		cout << g << endl;
	}

	return 0;
}