#include <iostream>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  string ans(N,'0');
  for(int i = 0; i < M; ++i){
    int s, c;
    cin >> s >> c;
    --s;
    if(ans[s] != '0' and ans[s] != '0'+c){
      puts("-1");
      return 0;
    }
    if(N > 1 and s == 0 and c == 0){
      puts("-1");
      return 0;
    }
    ans[s] = '0'+c;
  }
  if(N > 1 and ans[0] == '0') ans[0] = '1';
  cout << ans << endl;
}
