#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < m; ++i) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  bool ok = true;
  for (int i = 0; i < m; ++i) {
    for (int j = i + 1; j < m; ++j) {
      if (s[i] == s[j] && c[i] != c[j]) {
        ok = false;
      }
    }
    if (1 < n && s[i] == 0 && c[i] == 0) {
      ok = false;
    }
  }
  if (!ok) {
    cout << -1 << endl;
  } else {
    string ans = "";
    for (int i = 0; i < n; ++i) {
      ans += "?";
    }
    for (int i = 0; i < m; ++i) {
      ans[s[i]] = (char)(c[i] + '0');
    }
    for (int i = 0; i < n; ++i) {
      if (ans[i] == '?') {
        if (i == 0) {
          ans[i] = '1';
        } else {
          ans[i] = '0';
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
