Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

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 <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    // default
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.ignore(INT_MAX, '\n');
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_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;
    }
  } // while loop out
  return 0;
}

C++: #include<iostream>

using namespace std;

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

C++: #include <iostream>

using namespace std;

#define MAX_N (30)

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

int main()
{
    int w;  // 縦線
    int n;  // 横線
    int a, b;
    char c;
    int amida[MAX_N];
    
    cin >> w;
    for (int i = 0; i < w; i++){
        amida[i] = i + 1;
    }
    
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a >> c >> b;
        swap(&amida[a - 1], &amida[b - 1]);
    }
    
    for (int i = 0; i < w; i++){
        cout << amida[i] << endl;
    }
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
 
int main(){
int w,n,a,b,tmp;
char dummy;                //w:縦線 n:横線　それぞれの本数
 
cin >> w >> n;
 
int line[w];
for(int i=0;i<w;i++){
        line[i] = i + 1;
        }
 
 
 
while(cin >> a >>dummy >> b){
        tmp = line[a-1];
        line[a-1] = line[b-1];
        line[b-1] = tmp;
        }
 
for(int j=0;j<w;j++){
        cout << line[j] << endl;
        }
 
 
 
 
return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int a, b, v, h, tmp;
	char x;
	cin>>v;
	cin>>h;

	int num[v];
	//initialize array
	for(int i=0; i<v; i++){ num[i] = i+1; }
	
	for(int i=0; i<h; i++){
		cin>>a>>x>>b;
		swap(num[a-1], num[b-1]);
	}
	for(int i=0; i<v; i++) cout<<num[i]<<endl;
	return 0;
}

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

int main(){

int w, n;
int num[30]={0};
int a, b;

for(int i=0; i<w; i++)
num[i]=i+1;

cin>>w;
cin>>n;

for(int i=0; i<n; i++){

cin>>a,b;

int tmp=num[a];
num[a]=num[b];
num[b]=tmp;


}


for(int i=0; i<w; i++)
cout<<num[i]<<"\n";

return 0;

}

C++: #include <iostream>

void swap(int*, int, int);
void sepTwoNumbers(char*, int&, int&);
int char2Number(char*, int, int);

const int MAX_VIRTICAL_LINE = 30;
const int MAX_HORIZONTAL_LINE = 30;

int main(){
	int numOfVirticalLine;
	int numOfHorizontalLine;
	int amidaList[MAX_VIRTICAL_LINE] = {};

	for (int i = 0; i < MAX_VIRTICAL_LINE; i++)
	{
		amidaList[i] = i + 1;
	}

	std::cin >> numOfVirticalLine >> numOfHorizontalLine;
	for (int i = 0; i < numOfHorizontalLine; i++)
	{
		int line1, line2;
		char swapLineInfo[6];
		std::cin >> swapLineInfo;
		sepTwoNumbers(swapLineInfo, line1, line2);
		swap(amidaList, line1, line2);
	}
	for (int i = 0; i < numOfVirticalLine; i++)
	{
		std::cout << amidaList[i] << std::endl;
	}
	return 0;
}

void sepTwoNumbers(char* charOftwoNumber, int& number1, int& number2){
	int commaIndex;
	int endIndex;
	for (commaIndex = 0; charOftwoNumber[commaIndex] != ','; ++commaIndex);
	number1 = char2Number(charOftwoNumber, 0, commaIndex);
	for (endIndex = commaIndex; charOftwoNumber[endIndex] != '\0'; ++endIndex);
	number2 = char2Number(charOftwoNumber, commaIndex + 1, endIndex);
}

int char2Number(char* charNumber, int startDigit, int endDigit){
	int number = 0;
	for (int i = startDigit; i < endDigit; ++i){
		number *= 10;
		number += charNumber[i] - '0';
	}
	return number;
}

void swap(int* amidaList, int line1, int line2){
	int temp = amidaList[line1 - 1];
	amidaList[line1 - 1] = amidaList[line2 - 1];
	amidaList[line2 - 1] = temp;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int W, N, A[31], B[31], C[31];

	cin >> W >> N;

	for (int i = 1; i <= N; i++)
	{
		cin >> A[i] >> B[i];
	}

	for (int i = 1; i <= W; i++)
	{
		int t = i;

		for (int j = 1; j <= N; j++)
		{
			if (A[j] == t)
			{
				t = B[j];
			}
			else if (B[j] == t)
			{
				t = A[j];
			}
		}

		C[t] = i;
	}

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

	return 0;
}

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

using namespace std;

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

	vector<int> tate(w);

	for (int i = 0; i < w; ++i) {
		tate[i] = i + 1;
	}

	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a;
		cin.ignore(1);
		cin >> b;

		swap(tate[a - 1], tate[b - 1]);
	}

	for (auto temp : tate) {
		cout << temp << endl;
	}

}

C++: //#define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 30
int main(void)
{
	int w, n, a, b, x;
	int list[MAX] = { 0 };
	scanf_s("%d", &w);
	scanf_s("%d", &n);
	for (int i = 0; i < w;++i) {
		list[i] = i + 1;
	}
	for (int i = 0; i < n; ++i) {
		scanf_s("%d,%d", &a, &b);
		x = list[a - 1]; list[a - 1] = list[b - 1]; list[b - 1] = x;
	}
	for (int i = 0; i < w; ++i) {
		printf("%d\n", list[i]);
	}

}

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

C++: #include <cstdio>

using namespace std;

int line[32];
int w, n;

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

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

  for(int i=1;i<=w;i++)
    printf("%d\n", line[i]);
  
  return 0;
}

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

void swap(int a[], int k, int l) {
    int tmp = a[k];
    a[k] = a[l];
    a[l] = tmp;
}

int main(void) {
    int w, n, k, l;
    int a[31];
    cin >> w;
    cin >> n;
    for(int i = 1; i <= w; i++) {
        a[i] = i;
    }
    for(int j = 0; j < n; j++) {
        scanf("%d,%d", &k, &l);
        swap(a, k, l);
    }
    for(int i = 1; i <= w; i++) {
        printf("%d\n", a[i]);
    }
}