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

int main() {
	ios_base::sync_with_stdio( false );

	int w, n;
	cin >> w >> n;

	vector<pair<int, int>> hl( n );

	for( int i = 0; i < n; ++i ) {
		int a, b;
		char c;
		cin >> a >> c >> b;

		hl[i] = { a, b };
	}

	vector<int> vl( w+1 );

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

		for( int j = 0; j < n; ++j ) {
			if( x == hl[j].first ) {
				x = hl[j].second;
			}
			else if( x == hl[j].second ) {
				x = hl[j].first;
			}
		}

		vl[x] = i;
	}

	for( int i = 1; i <= w; ++i ) {
		cout << vl[i] << '\n';
	}
}

