#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  string s(N, 'a');
  for (int i = 0; i < (int)(M); i++) {
    int t;
    char c;
    cin >> t >> c;
    --t;
    if (s[t] == 'a' || s[t] == c) {
      s[t] = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (s[0] == '0' && N > 1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < (int)(N); i++) {
    if (s[i] == 'a') {
      if (i) {
        s[i] = '0';
      } else {
        s[i] = '1';
      }
    }
  }
  cout << s << endl;
}
