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