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



int main() {
  int n, m; ///n桁の数
  cin >> n >> m;
  int f = 0;
  vector<int> num(n, 0);
  vector<int> check(n, 0);
  rep(i, m){
    int s, c; ///s桁目の数がc
    cin >> s >> c;


    if(c == 0 && s == 1 && n!= 1) {
      f = 1;
      break;
    }
    else if(check[s-1] != 0 &&  num[s-1] != c){
      f = 1;
      break;
    }
    else if(c != 0){
      num[s-1] = c;
      check[s-1] = -1;
    }
    /*
    else{
      num[s-1] = c;
      check[s-1] = -1;
    }
    */
  }
  if (f == 1) cout << -1 << endl;
  else {
    if(chekck[0]==0){
      num[0] = 1;
    }
  
    
    rep(i, n) cout << num[i];
  }
    } 
   
  



