#include<iostream>
#include<vector>
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> s(m);
  vector<int> c(m);
  for(int i=0;i<m;i++){
    cin >> s[m] >> c[m];
  }
  vector<int> integer(n,0);
  for(int i=0;i<m;i++){
    if(integer[s[m]-1] == 0){
      integer[s[m]-1]=c[m];
    }else if(integer[s[m]-1] != 0){
      if(integer[s[m]-1]>c[m])
      else integer[s[m]-1]=c[m];
    }
  }
  if(integer[0]==0){
    cout << "-1" << endl;
  }else{
    for(int i=0;i<n;i++){
      cout << integer[i];
    }
    cout << endl;
  }
}
    