#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, m;
  cin >> n >> m;
  vector<char> a(n, '.');
  while (m--) {
    long long x, y;
    cin >> x >> y;
    if (a[x - 1] != '.' && a[x - 1] != (char)(y + '0')) {
      cout << -1;
      return 0;
    } else
      a[x - 1] = (char)(y + '0');
  }
  if (a[0] == '0' && n != 1) {
    cout << -1;
    return 0;
  }
  if (a[0] == '0' && n == 1) {
    cout << 0;
    return 0;
  }
  long long pos;
  char c;
  for (long long i = 0; i < n; i++) {
    if (a[i] != '.') {
      pos = i;
      c = a[i];
      break;
    }
  }
  if (c == '0') {
    a[0] = '1';
    for (long long i = 1; i < pos; i++) a[i] = '0';
  } else {
    for (long long i = 0; i < pos; i++) a[i] = '0';
  }
  for (long long i = pos; i < n; i++) {
    if (a[i] == '.') a[i] = '0';
  }
  for (auto i : a) cout << i;
}
