#include <bits/stdc++.h>
using ll = long long;
using namespace std;
template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  string ans = string(N, ' ');
  int s;
  char c;
  for (int i = int(0); i < int(M); ++i) {
    cin >> s >> c;
    if (ans.at(s - 1) == ' ' || ans.at(s - 1) == c)
      ans.at(s - 1) = c;
    else {
      ans.assign("-1");
      break;
    }
  }
  if (ans.length() > 1 && ans.at(0) == '0') ans.assign("-1");
  if (ans != "-1")
    for (int i = int(0); i < int(N); ++i)
      if (ans.at(i) == ' ') ans.at(i) = (i > 0 ? '0' : '1');
  cout << ans << endl;
}
