#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 10000007;
vector<long> divisor(long &_n) {
  vector<long> head, tail;
  for (long i = 1; i * i <= _n; i++) {
    if (_n % i == 0) {
      head.push_back(i);
      if (i * i != _n) tail.push_back(_n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return head;
}
long kadanes(vector<long> &_ls) {
  long highestmax = 0, currentmax = 0, length = _ls.size();
  for (long i = 0; i < length; i++) {
    currentmax = max(_ls[i], currentmax + _ls[i]);
    highestmax = max(highestmax, currentmax);
  }
  return highestmax;
}
struct init {
  init() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} init;
int main() {
  int n, m;
  cin >> n >> m;
  string s = string(n, '@');
  for (int i = 0; i < (m); i++) {
    int a;
    char b;
    cin >> a >> b;
    if (s[a - 1] != '@' and s[a - 1] != b) {
      cout << "-1\n";
      return 0;
    }
    s[a - 1] = b;
  }
  if (s[0] == '0') {
    cout << "-1\n";
    return 0;
  }
  bool tr = false;
  for (int i = 0; i < (m); i++) {
    if (s[i] != '@')
      tr = true;
    else {
      if (tr) {
        s[i] = '0';
      } else {
        s[i] = '1';
      }
    }
  }
  cout << s << "\n";
}
