#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,m;
cin >> n >> m;
int s;
char c;
char ans[n]={'x'};
int x;
bool flg = true;
REP(i,m) {
  cin >> s >> c;
  s--;
  if(ans[s]=='x'||ans[s]==c) {
    ans[s]=c;
  } else {
    flg = false;
  }
}
if(ans[0]==0) flg=false;
if(flg==true) {
  REP(i,n) {
    if(ans[i]=='x') {
      if(i==0) {
        cout << "1";
      } else {
        cout << "0";
      }
    } else {
      cout << ans[i];
    }
  }
  cout << endl;
} else {
  cout << "-1" << endl;
}
return 0;
}
