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


int main()
{
	int number[32];
	int index, pairnum;
	int a,b,tmp,i;
	cin >> index;
	cin >> pairnum;
	for( i = 0; i <32; i++ ) {
		number[i] = i;
	}

	for( i = 0; i < pairnum; i++ ) {
		scanf("%d,%d",&a,&b);
		tmp = number[a];
		number[a] = number[b];
		number[b]= tmp;
	}

	for( i = 1; i < index+1; i++ ) {
		printf("%d\n",number[i]);

	}

	return 0;
}

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

int main()
{
	int w;
	cin >> w;
	int n;
	cin >> n;
	vector<int> StartingPoint(w);
	for(int i = 0; i < w; i++){
		StartingPoint[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		int HorizonalLineLeft;
		int HorizonalLineRight;
		char Dummy;
		cin >> HorizonalLineLeft >> Dummy >> HorizonalLineRight;
		swap(StartingPoint[HorizonalLineLeft-1], StartingPoint[HorizonalLineRight-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}

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

int main()
{
	int linecount = 0;
	std::scanf("%d", &linecount);

	std::vector<int> result(linecount);
	for (int i = 0; i < linecount; ++i) {
		result[i] = i + 1;
	}

	int swapcount = 0;
	std::scanf("%d", &swapcount);
	for (int i = 0; i < swapcount; ++i) {
		int swap1, swap2;
		if (std::scanf("%d,%d", &swap1, &swap2) == 2) {
			std::swap(result[swap1 - 1], result[swap2 - 1]);
		}
	}

	for (int i = 0; i < linecount; ++i) {
		std::printf("%d\n", result[i]);
	}

	return 0;
}

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

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

	vector<int> result(w);
	iota(result.begin(), result.end(), 1);

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

	for(const auto &from : result) {
		cout << from << endl;
	}

	return EXIT_SUCCESS;
}

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

#define rep(i, n) for(int i = 0; i < n; i ++)

using namespace std;

int main(){
	int w; cin >> w;
	vector<int> amida;
	rep(i, w) amida.push_back(i + 1);
	int n; cin >> n;
	while(n --){
		int before, after;
		scanf("%d,%d", &before, &after);
		swap(amida[before - 1], amida[after - 1]);
	}
	rep(i, w) cout << amida[i] << endl;
	
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

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

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

#define add push_back
#define inf 2147000000

#define rep(i,n) for(int i=0;i<n;i++)
#define out(a) cout<<a<<endl;

using namespace std;

int main(void){
	int w,h;
	int y1[30],y2[30],t[31];
	string str;
	scanf("%d%d",&w,&h);
	rep(i,h){
		cin>>str;
		y1[i] = str[0]-48;
		y2[i] = str[2]-48;
	}
	rep(i,31)t[i]=i;
	
	rep(i,h){
		swap(t[y1[i]],t[y2[i]]);
	}
	
	rep(i,w)out(t[i+1]);
}

C++: #include<iostream>
using namespace std;
int main()
{
  int tate,yoko,lot[31];
  cin >> tate >> yoko;
  for(int i=1; i<=tate; i++)
    lot[i]=i;
  while(yoko-->0){
    int a,b,temp;
    char x;
    cin >> a >> x >> b;
    temp=lot[a];
    lot[a]=lot[b];
    lot[b]=temp;
  }
  for(int i=1; i<=tate; i++)
    cout << lot[i] << endl;
}

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

pair<int, int> p;
int a[31];

int main()
{
	int w, n, r;
	cin >> w >> n;
	for (int i = 1; i < w + 1; i++)
		a[i] = i;
	for (int i = 0; i < n; i++)
	{
		scanf_s("%d,%d", &p.first, &p.second);
		r = a[p.first];
		a[p.first] = a[p.second];
		a[p.second] = r;
	}
	for (int i = 1; i < w + 1; i++)
	{
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void){
	int w,n;
	int a,b;
	int i;
	char ch;
	int m[31];
	cin>>w>>n;
	for(i=1;i<=w;i++)	m[i]=i;
	for(i=0;i<n;i++){
		cin>>a>>ch>>b;
		swap(m[a],m[b]);
	}
	for(i=1;i<=w;i++)	cout<<m[i]<<endl;
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=30;

int n,w;
int a[MAX_N],b[MAX_N];

char s[8];

int main(){
	scanf("%d",&w);
	scanf("%d",&n);
	REP(i,n){
		scanf("%s",s);
		int l=strlen(s);
		b[i]=-1;
		REP(j,l){
			if (s[j]!=','){
				if (b[i]==-1){
					a[i]*=10;
					a[i]+=s[j]-'0';
				}
				else{
					b[i]*=10;
					b[i]+=s[j]-'0';
				}
			}
			else{
				b[i]=0;
			}
		}
	}
	FOR(i,1,w+1){
		int c=i;
		for(int j=n-1;j>=0;j--){
			if (c==a[j]){
				c=b[j];
			}
			else if (c==b[j]){
				c=a[j];
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

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

int main(){

	using namespace std;

	vector<int> array;
	int w,n;
	int a,b,i,j;
	
	scanf("%d %d\n",&w,&n);
	
	for(i=0;i<w;i++){
		array.push_back(i+1);
	}
	
	for(i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		array[a-1]=b;
		array[b-1]=a;
	}
	
	for(i=0;i<w;i++){
		cout << array[i] << endl;
	}
}

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

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

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

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

void swap(int *VerticalLine, int a, int b)
{
	int temp;

	temp = VerticalLine[a];
	VerticalLine[a] = VerticalLine[b];
	VerticalLine[b] = temp;
	
	return;
}

int main(void)
{
	int *VerticalLine;
	int *a, *b;
	int w, n;
	int i;
	
	scanf("%d", &w);
	scanf("%d", &n);
	
	VerticalLine = (int *)malloc(sizeof(int) * w);
	for(i = 0; i < w; ++i)
	{
		VerticalLine[i] = (i + 1);
	}
	a = (int *)malloc(sizeof(int) * n);
	b = (int *)malloc(sizeof(int) * n);
	
	for(i = 0; i < n; ++i)
	{
		scanf("%d,%d", &a[i], &b[i]);
	}
	
	for(i = 0; i < n; ++i)
	{
		swap(VerticalLine, (a[i] - 1), (b[i] - 1));
	}
	
	for(i = 0; i < w; ++i)
	{
		printf("%d\n", VerticalLine[i]);
	}
	
	free(VerticalLine);
	free(a);
	free(b);
	return 0;
}

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

int main(){
	int line[31];
	int w, n;
	string str;
	getline( cin, str );
	sscanf( str.c_str(), "%d", &w );
	getline( cin, str );
	sscanf( str.c_str(), "%d", &n );

	for( int i=1; i<=w; i++ ){
		line[i] = i;
	}
	for( int i=0; i<n; i++ ){
		int a, b;
		getline( cin, str );
		sscanf( str.c_str(), "%d,%d", &a, &b );
		int tmp = line[a];
		line[a] = line[b];
		line[b] = tmp;
	}

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