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