#include<iostream>
#include<string>
#include<iomanip>
#include<sstream>
#include<regex>

#define rep(i,n) for(int i = 0;i < n;++i)

using namespace std;

int main()
{
    ostringstream oss;
    int n,m,a=1,b,x,y,sum=0;
    int flag = 0;
    char c;
    string s;
    cin >> n >> m;
  	if(n==1){
      cout << "0" << endl;
      return 0;
    }
    rep(i,n-1) a  *= 10;
    oss << a;
    s = oss.str();
    rep(i,m){
        cin >> x >> c;
        if(x == 1 && c == '0' && n != 1 || n < x){
            flag = 1;
            break;
        }
        if(s[x-1] == '0' || s[x-1] == c){
            s[x-1] = c; 
        }else if(x==1&&s[x-1]=='1'){
             s[x-1] = c;
        }else{
            flag = 1;
            break;
        }
    }
    if(!flag) cout << s << endl;
    if(flag) cout << "-1" << endl
    return 0;
}