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