#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  string s = "";
  for (int i = 0; i < (n); ++i) s += "?";
  for (int i = 0; i < (m); ++i) {
    int k;
    char c;
    cin >> k >> c;
    if (k == 1 && c == '0') {
      cout << -1 << endl;
      return 0;
    }
    k--;
    if (s[k] == '?')
      s[k] = c;
    else if (s[k] == c)
      continue;
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (n == 1 && s[0] == '?') s[0] = '0';
  if (s[0] == '?') s[0] = '1';
  for (int i = 0; i < (n); ++i) {
    if (s[i] == '?') s[i] = '0';
  }
  cout << s << endl;
  return 0;
}
