using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var zen = Console.ReadLine().Split();
    var n = int.Parse(zen[0]);
    var m = int.Parse(zen[1]);
    var a = new int[n];
    
    if(m == 0){
      string f = "1";
      for(var i = 0;i<n-1;i++){
        f = f+"0";
      }
      Console.WriteLine(f);
      return;
    }
    
    for(var i = 0;i<n;i++){
      a[i] = 10;
    }
    for(var i = 0;i< m ;i++){
      var sc = Console.ReadLine().Split();
      var s = int.Parse(sc[0]);
      var c = int.Parse(sc[1]);
      if(a[s-1] == 10){a[s-1] = c;}
      else if(a[s-1] == c){a[s-1] = c;}
      else{
        Console.WriteLine("-1");
        return;
      }  
    }
    for(var i = 0;i<n;i++){
      if(a[0] == 10){a[0] = 1;continue;}
      if(a[i]== 10){a[i] =0;}
    }
    for(var i = 0;i<n;i++){
      if(n>=2&&a[0] == 0){Console.WriteLine("-1");return;}
      Console.Write(a[i]);
    }
  }
}