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