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