#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int M = 1e9+7;    
const int N = 5e5;  // limit for array size
int tests() {
  int n,m,k ; 
  int i,s,c ; 
  cin >>  n >> m     ;
  std::vector<int> book(n,10);
  forn(i,0,m){
    cin >> s >> c ; 
    if(book[s-1] == 10 )
      book[s-1] = c ; 
    else if(book[s-1] != c )
        return cout << -1 ,0 ; 
  }
  forn(i,1,n)
    if(book[i] == 10)
      book[i] = 0 ; 
  if(book[0] == 10 )
    book[0] = 1 ;
  if(book[0] == 0 && n > 1 )
    return cout << -1,0 ; 
       
  forn(i,0,n)
    cout << book[i] ;
  
  return 0; 
}
int main(){
    I__O ;  
    int cases = 1 ;
    // cin >> cases ; 
    while(cases--)
      tests(); 
  return 0 ; 
}