#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> v(3, -1);
  bool ok = true;
  for (int i = (int)(0); i < (int)(M); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (v[s] != -1 && v[s] != c) ok = false;
    v[s] = c;
  }
  if (N == 1) {
    if (v[0] == -1)
      cout << 0 << endl;
    else
      cout << v[0] << endl;
    return 0;
  }
  string ans = "";
  if (v[0] == 0)
    ok = false;
  else if (v[0] == -1)
    ans += '1';
  else
    ans += v[0] + '0';
  for (int i = (int)(1); i < (int)(N); i++) {
    if (v[i] == -1)
      ans += '0';
    else
      ans += v[i] + '0';
  }
  cout << (ok ? ans : "-1") << endl;
}
