#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)

int main(void){
    // Your code here!
   int n,m;
   cin >> n >> m;

   int num = 1;
   rep(i,n-1) num *= 10;
   //int d[n] ={};
   vector <int> d(n,0);
   
   string cou = to_string(num);
   
   int f = 0;
   rep(i,m){
     int a;
     char b;
     cin >> a >> b;

     if((a==1 && b=='0')  f = 1;
     if( d[a-1] ==1 && cou[a-1]!=b) f = 1;
     d[a-1] = 1;
     cou[a-1] = b;
    
   }  
   
   if (f == 1) cout << -1 << endl;
   else cout << cou << endl;
}
