#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char s[n];
  for (int i = 0; i < n; i++) {
    if (i == 0 && n != 1)
      s[i] = '1';
    else
      s[i] = '0';
  }
  bool f[n + 10];
  for (int i = 0; i < n + 10; i++) f[i] = true;
  for (int i = 0; i < m; i++) {
    int p, q;
    cin >> p >> q;
    if (f[p - 1] == true || s[p - 1] == '0' + q) {
      if (p == 1 && q == 0) {
        cout << "-1" << endl;
        return 0;
      }
      s[p - 1] = '0' + q;
      f[p - 1] = false;
    } else {
      cout << "-1" << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) cout << s[i];
  cout << endl;
  return 0;
}
