#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  bool ok = true;
  map<int, int> ma;
  for (long long i = 0; i < (long long)m; i++) {
    int s, c;
    cin >> s >> c;
    if (ma.count(s) && ma[s] != c) ok = false;
    ma[s] = c;
    if (s == 1 && c == 0) ok = false;
  }
  string res(n, '0');
  for (auto i : ma) {
    res[i.first - 1] = i.second + '0';
  }
  if (n > 1) {
    reverse(res.begin(), res.end());
    for (int i = n - 1; i >= 0; i--) {
      if (res[i] == '0')
        res.pop_back();
      else
        break;
    }
    reverse(res.begin(), res.end());
  }
  if (ok)
    cout << res << endl;
  else
    cout << -1 << endl;
  return 0;
}
