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