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