#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long a, long long m) { return (a % m + m) % m; }
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int n, m, a[10], b[10];
void solve() {
  cin >> n >> m;
  char c[3] = {'.', '.', '.'};
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    c[a[i]] = (char)('0' + b[i]);
  }
  for (int i = 0; i < m; i++) {
    if (c[a[i]] != (char)('0' + b[i])) {
      cout << -1 << endl;
      return;
    }
  }
  for (int i = 0; i < n; i++) {
    if (c[i] == '.') {
      if (i == 0)
        cout << 1;
      else
        cout << 0;
    } else {
      if (i == 0 && c[i] == '0' && n != 1) {
        cout << -1 << endl;
        return;
      }
      cout << c[i];
    }
  }
  cout << endl;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
