#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
template <typename T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int main(void) {
  int n, m;
  cin >> n >> m;
  string s(n, '*');
  for (int i = 0; i < m; ++i) {
    int c, x;
    cin >> c >> x;
    c--;
    char d = '0' + x;
    if (s[c] == '*')
      s[c] = d;
    else if (s[c] != d) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (s[i] == '*') {
      if (i == 0)
        s[i] = '1';
      else
        s[i] = '0';
    } else if (i == 0 && s[i] == '0') {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << s << endl;
  return 0;
}
