#include <iostream>
#include <string>
#include <cmath>
using namespace std;
typedef long long llint;
llint n,m;
llint a[5];

void solve(){
  cin >> n >> m;
  llint s, c;
  for(int i = 1; i <= n; i++) a[i] = -1;
  for(int i = 1; i <= m; i++){
    cin >> s >> c;
    if(a[s] != -1 && a[s] != c){
      cout << -1 << endl;
      return 0;
    }
    a[s] = c;
  }

  if(n == 1){
    if(a[1] <= 0){
      cout << 0 << endl;
      return 0;
    }
  }

  if(a[1] == 0){
    cout << -1 << endl;
    return 0;
  }
  if(a[1] == -1) a[1] = 1;
  for(int i = 2; i <= n; i++){
    if(a[i] == -1) a[i] = 0;
  }

  for(int i = 1; i<= n; i++)  cout << a[i]; cout << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}
