Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	lines, _ := strconv.Atoi(sc.Text())
	l := make([]int, lines)
	for i := 0; i < lines; i++ {
		l[i] = i + 1
	}

	sc.Scan()
	rows, _ := strconv.Atoi(sc.Text())
	for i := 0; i < rows; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), ",")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])

		l[a-1], l[b-1] = l[b-1], l[a-1]
	}
	for _, j := range l {
		fmt.Println(j)
	}
}

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

int main(){
	int str[30];
	int w, n, i;
	int a, b;
	int t;

	cin >> w;
	cin >> n;

	for (i = 0; i < 30; i++){
		str[i] = i + 1;
	}

	for (i = 0; i < n; i++){
		scanf("%d,%d", &a, &b);
		
		t = str[a - 1];
		str[a - 1] = str[b - 1];
		str[b - 1] = t;
	}
	for (i = 0; i < w; i++){
		cout << str[i] << "\n";
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
	int tate,yoko,bou[30][2],j,x,kekka[]={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},i=0;
	scanf("%d %d",&tate,&yoko);
	for(j=0;j<yoko;j++){
		scanf("%d",&bou[j][1]);
		printf(",");
		scanf("%d",&bou[j][2]);
	}
	for(i=1;i<tate+1;i++){
		x=i;
		for(j=0;j<yoko;j++){
			if(bou[j][1]==x){
				x=bou[j][2];
			}
			else if(bou[j][2]==x){
				x=bou[j][1];
			}
		}
		kekka[x-1]=i;
	}
	for(j=0;j<tate;j++){
		printf("%d\n",kekka[j]);
	}
}

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;
		int m;
		rep(j,4)if(str[j]==','){m=j;break;}
		
		switch(m){
			case 1:
				y1[i]=str[0]-48;
				break;
			case 2:
				y1[i]= (str[0]-48)*10;
				y1[i]+=str[1]-48;
				break;
		}
		if(str[m+2]!='\0'){
			y2[i] = (str[m+1]-48) * 10;
			y2[i] += str[m+2]-48;
		}else{
			
			y2[i] = str[m+1]-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>
#include <string>
using namespace std;


int main()
{
	int w, n, num[32];
	string s;
	cin >> w;
	fill(num, num + 32, 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 = stoi(l);
		int right = stoi(r);
		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<iostream>
#include<vector>
#include<string>
int main(){
	int w,h;
	std::cin>>w>>h;
	std::vector<int> vec(w);
	for(int i=0;i<w;++i)vec[i]=i+1;
	for(int i=0;i<h;i++){
		std::string str;
		std::cin>>str;
		{
			char c=str[0],d=str[2];
			int a=c-'0'-1,b=d-'0'-1;
			int n=vec[a];
			vec[a]=vec[b];
			vec[b]=n;
		}
	}
	for(int i=0;i<w;i++){
		std::cout<<vec[i]<<std::endl;
	}

	return 0;
}

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

using namespace std;

struct Horizontal {
	int pointA;
	int pointB;
};

inline static Horizontal perse_linecomb(string comb);

inline static Horizontal perse_linecomb(string comb) {
	Horizontal horizon;
	int canma_point = comb.find(",");

	horizon.pointA = stoi(comb.substr(0,canma_point));
	horizon.pointB = stoi(comb.substr(canma_point + 1));

	return horizon;
}

int main(void) {
	int vertical_num;
	int horizontal_num;

// enter number of vertical line
	// cout << "enter vertical line number:";
	cin >> vertical_num;
	vector<int> line(vertical_num);
	for(int i = 0; i < vertical_num; i++) {
		line.at(i) = i + 1;
	}

// enter number of horizontal line
	// cout << "enter horizontal line number:";
	cin >> horizontal_num;

//
	vector<Horizontal> horizontal_line(horizontal_num);
	// cout << "enter " << horizontal_num << " points" << endl;
	for(int i = 0; i < horizontal_num; i++) {
		string comb;
		// cout << i + 1 << " line: ";
		cin >> comb;
		horizontal_line.at(i) = perse_linecomb(comb);
	}

	for(const Horizontal &x : horizontal_line) {
		int temp;
		temp = line.at(x.pointA - 1);
		line.at(x.pointA - 1) = line.at(x.pointB - 1);
		line.at(x.pointB - 1) = temp;
	}

// print console
	for(int i = 0; i < vertical_num; i++) {
		cout << line.at(i) << endl;
	}

}

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

int main(){
	int n, m;
	cin >> n >> m;
	int a[n];
	for(int i = 0; i < n; i++){
		a[i] = i+1;
	}
	for(int i = 0; i < m; i++){
		stringstream ss1, ss2;
		string str;
		int p, q;
		cin >> str;
		ss1 << str[0];
		ss2 << str[2];
		ss1 >> p;
		ss2 >> q;
		swap(a[p-1],a[q-1]);
	}
	for(int i = 0; i < n; i++){
		cout << a[i] << endl;
	}
}

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

using namespace std;

int main() {
	int w, n;
	int change[30][2];
	int line[30];
	cin >> w >> n;
	for (int i = 0; i < n; ++i) {
		scanf_s("%d,%d", &change[i][0], &change[i][1]);
	}
	
	for (int i = 0; i < w; ++i) {
		line[i] = i + 1;
	}
	for (int i = 0; i < n; ++i) {
		swap(line[change[i][0] - 1], line[change[i][1] - 1]);
		//for (int i = 0; i < w; ++i) {
		//	cout << line[i] << " ";
		//}
		//cout << endl;
		//cout << "--------------------------" << endl;
	}
	for (int i = 0; i < w; ++i) {
		cout << line[i] << endl;;
	}
}

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

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

C++: #include <stdio.h>

int main(void)
{
	int w,n;
	char str[4];
	int l1, l2;
	int ans[30];
	int i;
	
	scanf("%d %d", &w, &n);
	
	for (i = 0; i < w; i++){
		ans[i] = i + 1;
	}
	
	while (n){
		scanf("%s", str);
		
		l1 = str[0] - '1';
		l2 = str[2] - '1';
		
		ans[l1] += ans[l2];
		ans[l2] = ans[l1] - ans[l2];
		ans[l1] -= ans[l2];
		
		n--;
	}
	
	for (i = 0; i < w; i++){
		printf("%d\n", ans[i]);
	}
	
	return (0);
}

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

using namespace std;

void swap(int *var1, int *var2) {
  int tmp = *var1;
  *var1 = *var2;
  *var2 = tmp;
}

int main() {
  int w;
  int n;

  cin >> w;
  cin >> n;

  int vertical_line[w];
  for (int v_i = 0; v_i < w; v_i++)
    vertical_line[v_i] = v_i;

  for (int n_i = 0; n_i < n; n_i++) {
    int node1, node2;
    scanf("%d,%d", &node1, &node2);
    swap(vertical_line+node1, vertical_line+node2);    
  }

  for (int v_i = 0; v_i < w; v_i++)
    cout << vertical_line[v_i] << endl;

  return 0;
}

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

using namespace std;
static const int MAXV = 32;

int main() {
  int w, n, A[MAXV], a, b, tmp;
  scanf("%d %d", &w, &n);
  for(int i=1;i<w+1;i++)
    A[i]=i;
  //for(int i=0;i<w+1;i++)
  //  printf("%d\n", A[i+1]);
  for(int i=0;i<n;i++) {
    scanf("%d,%d", &a, &b);
    //printf("%d %d\n", a, b);
    tmp=A[a];
    A[a]=A[b]; A[b]=tmp;
    //printf("\n%d %d %d %d %d\n", A[1], A[2], A[3], A[4], A[5]);
  }
  for(int i=1;i<w+1;i++)
    printf("%d\n", A[i]);
}

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

using namespace std;

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

	int kuji[n], a[n], b[n];
	for (int i = 1; i <= w; i++) kuji[i] = i;

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

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