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