//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  int s,c;
  int chk[n+1] = {0};
  bool flag = true;
  rep(i,m){
    cin >> s >> c;
    if(s==1){
      if(c==0){
        flag = false;
      }
    }
    if(chk[s] == 0) chk[s] = c;
    else{
      if(chk[s] != c) flag = false;
    }
  }
  if(!flag){
    printf("-1\n");
    return 0;
  }
  if(chk[1]==0) chk[1] = 1;
  for(int i = 1; i <= n; i++){
    printf("%d", chk[i]);
  }
  printf("\n");

  return 0;
}
