#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<int>>;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> second(m);
  vector<char> c(m);
  string a;
  for (long long i = 0; i < (long long)(n); i++) a[i] = 'a';
  for (long long i = 0; i < (long long)(m); i++) {
    cin >> second[i] >> c[i];
    if (second[i] == 1 && c[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (long long i = 0; i < (long long)(m); i++) {
    if (a[second[i] - 1] != 'a' && a[second[i] - 1] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
    a[second[i] - 1] = c[i];
  }
  if (a[0] == 'a') a[0] = '1';
  for (long long i = 1; i <= (long long)(n - 1); i++)
    if (a[i] == 'a') a[i] = '0';
  for (long long i = 0; i < (long long)(n); i++) cout << a[i];
  cout << endl;
}
