#include<iostream>

using namespace std;
 
int main() {
	
    int L[30];
    for(int i=0;i<30;i++)
	L[i]= i + 1;
	
    int a,b;
    cin >> a >> b;
    for(int i=0;i<b;i++){
    	
        int c,d;
        cin >> c >> d;
        
        int s = L[c-1];
        L[c-1] = L[d-1];
        L[d-1] = s;
        
    }
    for(int i=0;i<a;i++)
	cout << L[i] << "\n";
	return 0;
}
