#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
int main() {
  int N, M;
  cin >> N >> M;
  int a[3];
  for (int i = 0; i < (int)(3); ++i) {
    a[i] = -1;
  }
  for (int i = 0; i < (int)(M); ++i) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0) {
      if (N != 1 && c == 0) {
        cout << -1 << endl;
        return 0;
      }
    }
    if (a[s] == -1) {
      a[s] = c;
    } else if (a[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < (int)(N); ++i) {
    if (i == 0) {
      if (a[i] == -1) {
        a[i] = 1;
      }
    } else {
      if (a[i] == -1) {
        a[i] = 0;
      }
    }
  }
  for (int i = 0; i < (int)(N); ++i) {
    cout << a[i];
  }
  cout << endl;
  return 0;
}
