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<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_s("%d,%d",&a,&b);
		swap(c[a],c[b]);
	}
	for(int i=1;i<=w;i++)cout<<c[i]<<endl;
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

int main()
{
	int w, n, a, b;
	char comma;
	vector<int> vec;

	cin >> w;
	cin >> n;

	for (int i = 1; i <= w; i++)
	{
		vec.push_back(i);
	}

	for (int i = 0; i < n; i++)
	{
		cin >> a >> comma >> b;
		
		swap(vec[a - 1], vec[b - 1]);
	}

	for (auto a : vec)
	{
		cout << a << endl;
	}


	return 0;
}

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

int main()
{
	int w,wl[35],n,a,b,c;
	char ch;
	for(int i=0;i<35;i++){
		wl[i]=i;
	}
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		cin>>ch;
		cin>>b;
		c=wl[a];
		wl[a]=wl[b];
		wl[b]=c;
	}
	for(int i=0;i<w;i++){
		cout<<wl[i+1]<<endl;
	}
}

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

typedef std::pair<int, int> swap_command;

int w, n;
std::vector<int> vertical;
std::vector<swap_command> commands;

swap_command get_command_input()
{
	swap_command cmd;
	char dummy;
	std::cin >> cmd.first >> dummy >> cmd.second;
	return cmd;
}

void init()
{
	std::cin >> w;
	std::cin >> n;

//	std::cout << w << " " << n << std::endl;

	int i;
	for (i = 0; i < w; i++) {
		vertical.push_back(i+1);
	}

	for (i = 0; i < n; i++) {
		commands.push_back(get_command_input());
	}
}

void dump_vertical()
{
	std::cout << "vertical: ";
	for (int i = 0; i < w; i++) {
		std::cout << vertical[i] << ' ';
	}
	std::cout << std::endl;
}

void swap(swap_command cmd)
{
//	std::cout << "fist: " << cmd.first << " second: " << cmd.second << std::endl;
	int i = cmd.first-1;
	int j = cmd.second-1;
	int tmp = vertical[i];
	vertical[i] = vertical[j];
	vertical[j] = tmp;
//	dump_vertical();
}

void solve()
{
	for (std::vector<swap_command>::iterator i = commands.begin(); i != commands.end(); i++) {
		swap(*i);
	}
}

void output()
{
	for (std::vector<int>::iterator i = vertical.begin(); i != vertical.end(); i++) {
		std::cout << *i << std::endl;
	}
}

int main()
{
	init();
	solve();
	output();
	return 0;
}

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


 int main(){

   int w,n,u,t,p;
   cin >> w>>n;
   int a[w];
   for(int i=0; i<w;i++)
    a[i]=i+1;

   for(int i=0; i<n;i++){
     scanf("%d,%d\n",&u,&t);
     p=a[t-1]; a[t-1]=a[u-1];a[u-1]=p;
   }
   for(int i=0; i<w ;i++)printf("%d\n",a[i]);
 }

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

int main() {
	int w, n, a, b;

	cin >> w >> n;
	vector<int> hlines(w);
	for (int i = 0; i < w; ++i) {
		hlines.at(i) = i + 1;
	}

	for (int i = 0; i < n; ++i) {
		cin >> a;
		cin.ignore();
		cin >> b;
		--a, --b;
		swap(hlines.at(a), hlines.at(b));
	}
	for (int i = 0; i < w; ++i) {
		cout << hlines.at(i) << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int w, n;
    char comma;
    int ab[31][2];
    int ans[31];
    
    cin >> w >> n;
    for (int i = 0; i < n; i++)
        cin >> ab[i][0] >> comma >> ab[i][1];

    for (int i = 1; i <= w; i++) {
        int state = i;
        int pos = 0;
        for (int j = 0; j < n; j++) {
            if (pos == 0) {
                if (ab[j][0] == state) {
                    state = ab[j][1];
                    pos = 1;
                }
                else if (ab[j][1] == state) {
                    state = ab[j][0];
                    pos = -1;
                }
            }
            else if (pos == -1 && ab[j][0] == state) {
                state = ab[j][1];
                pos = 1;
            }
            else if (pos == 1 && ab[j][1] == state) {
                state = ab[j][0];
                pos = -1;
            }
        }
        ans[state] = i;
    }

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

    return 0;
}

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

int main() {
	int w, n, a, b;
	int amida[31];
	for (int i = 1;i < 31;i++) amida[i] = i;
	cin >> w >> n;

	for (int i = 0;i < n;i++) {
		cin >> a >> b;
		swap(amida[a], amida[b]);
	}

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

	return 0;
}

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

int main(int argc, const char * argv[])
{
    int w, n;
    std::cin >> w >> n;
    int a[w];
    for (int i = 0; i < w; i++) {
        a[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        int aa, bb, tmp;
        scanf("%d,%d", &aa, &bb);
        tmp = a[aa - 1];
        a[aa - 1] = a[bb - 1];
        a[bb - 1] = tmp;
    }
    for (int i = 0; i < w; i++) {
        printf("%d\n", a[i]);
    }
    
    return 0;
}

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

int main()
{
	int w;cin>>w;
	int n;cin>>n;
	vector<int>P(w+1);
	for ( int i=0; i<=w; i++ )
		P[i]=i;
	for ( int i=0; i<n; i++ )
	{
		int a,b;
		char c;
		cin>>a>>c>>b;
		swap(P[a],P[b]);

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



}

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

using namespace std;

int main() {

	int w;
	int n;
	int number[30] = {0};
	int kari;
	int a, b;
	char c;

	cin >> w;
	cin >> n;

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

	for(int i = 0; i < n; i++) {
		cin >> a >> c >> b;
		kari = number[a-1];
		number[a-1] = number[b-1];
		number[b-1] = kari;
	}

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

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int* a;

void swap(int j, int k) {
    int temp = a[j];
    a[j] = a[k];
    a[k] = temp;
}

int main() {
    int w, n;
    cin >> w >> n;
    a = new int[w];
    REP(i,w) {
        a[i] = i+1;
    }
    REP(i,n) {
        int j, k;
        scanf("%d,%d", &j, &k);
        swap(j-1, k-1);
    }
    REP(i,w) {
        cout << a[i] << endl;
    }
    delete[] a;
    return 0;
}

C++: #include<iostream>
int main(){
	int w,n,a[30][2],b[30];
	std::cin>>w
		>>n;
	for(int i=0;i<n;++i){
		for(int j=0;j<2;++j){
			std::cin>>a[i][j];
		}
	}
	for(int i=1;i<=w;++i){
		b[i]=i;
	}
	for(int i=0;i<n;++i){
			int x=b[a[i][0]];
			b[a[i][0]]=b[a[i][1]];
			b[a[i][1]]=x;
	}
	for(int i=1;i<=w;++i){
		std::cout<<b[i]<<std::endl;
	}
	return 0;
}