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

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> vec_a(M, vector<int>(2));
    vector<int> vec_b(N, 0);

    for(int i = 0; i < M; i++){
    for (int j = 0; j < 2; j++){
        cin >> vec_a[i][j];
    }
}

for(int i = 0; i < M; i++){
        for(int j = 1; i < j < M; j++){
            if(vec_a[i][0] == vec_a[j][0] && vec_a[i][1] != vec_a[j][1]){
                cout << "-1" <<endl;
                goto end1; 

            }
    }
}


   for(int i = 0; i < M; i++){
       vec_b[(vec_a[i][0])-1] = vec_a[i][1];
   } 

   if(vec_b[0] == 0){
       cout << "-1" <<endl;
       goto end1;
   }
   for (int i = 0; i < M; i++){

   
    cout << vec_b[i]<<endl;}

end1:

}