#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  string S;
  if (N == 0)
    S = "0";
  else {
    for (int i = 0; i < N; i++) {
      if (i == 0)
        S.push_back('1');
      else
        S.push_back('0');
    }
  }
  map<int, int> mp;
  bool ok = true;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (mp.find(s) != mp.end() && mp[s] != c) {
      ok = false;
    } else {
      S[s] = char(c + '0');
      mp[s] = c;
    }
  }
  if (S[0] == '0' && S.size() > 1) {
    ok = false;
  }
  if (!ok)
    cout << -1 << endl;
  else
    cout << S << endl;
  return 0;
}
