#include<iostream>

using namespace std;
 
int main(){
    int W,N;
    int w[30];
 
    cin >> W >> N;

    for(int i=0;i<W;i++)
    w[i] = i+1;
 
    int a, b, dm;
    for(int i=0;i<N;i++) {
    	
        cin >> a >> b; 
        
        dm = w[a-1];
        w[a-1] = w[b-1];
        w[b-1] = dm;
        
        }
 
        for(int i=0;i<W;i++)
            cout << w[i] << "\n"; 
 
        return 0;
}
