#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, a, b;
  cin >> n >> m;
  string str(n, '@');
  bool ans = true;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (str[a - 1] != '@' && str[a - 1] != (char)(b + 48)) {
      ans = false;
      continue;
    }
    str[a - 1] = (char)(b + 48);
  }
  if (!ans || (n > 1 && str[0] == '0'))
    cout << -1 << "\n";
  else {
    for (int i = 0; i < n; i++) {
      if (str[i] == '@') str[i] = '1';
    }
    cout << str << "\n";
  }
}
int main() {
  solve();
  return 0;
}
