#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, k, j, w, val;
  cin >> n >> m;
  int a[n];
  for (i = 0; i < n; i++) {
    a[i] = -1;
  }
  for (i = 0; i < m; i++) {
    {
      cin >> k;
      cin >> val;
      w = k - 1;
      if (a[w] == -1) {
        a[w] = val;
      } else if (a[w] != val && a[w] != -1) {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  if (n > 1 && a[0] == 0) {
    cout << "-1" << endl;
    return 0;
  }
  if (n >= 2 && a[1] != 0 && a[0] == -1) {
    a[0] = 1;
  }
  for (i = 0; i < n; i++) {
    if (a[i] == -1) {
      a[i] = 0;
    }
    cout << a[i];
  }
  cout << endl;
  return 0;
}
