#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t, n;
  cin >> n >> t;
  int a[3] = {-1, -1, -1};
  while (t--) {
    int x, y;
    cin >> x >> y;
    x -= 1;
    if ((a[x] == -1 || a[x] == y)) {
      a[x] = y;
    } else {
      cout << "-1";
      return 0;
    }
    if (a[0] == 0 && n > 1) {
      cout << "-1";
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[0] == -1) {
      a[0] = 1;
    } else if (a[i] == -1) {
      a[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i];
  }
  return 0;
}
