#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
const long long int INF = 1e8;
signed main() {
  long long int N, M;
  cin >> N >> M;
  vector<long long int> s(M), c(M);
  vector<long long int> v(N, INF);
  bool isOK = true;
  for (long long int i = 0; i < (long long int)(M); i++) {
    cin >> s[i] >> c[i];
    if (s[i] == 1 && c[i] == 0) isOK = false;
    if (v[s[i] - 1] == INF)
      v[s[i] - 1] = c[i];
    else if (v[s[i] - 1] == c[i])
      continue;
    else
      isOK = false;
  }
  if (!isOK) {
    cout << -1;
    return 0;
  }
  string S;
  for (long long int i = 0; i < (long long int)(N); i++) {
    if (!i)
      S.push_back('1');
    else
      S.push_back('0');
  }
  for (long long int i = 0; i < (long long int)(M); i++) {
    char tmp = '0' + c[i];
    S[s[i] - 1] = tmp;
  }
  for (long long int i = 0; i < (long long int)(N); i++) cout << S[i];
}
